Fix project isolation: Make loadChatHistory respect active project sessions
- Modified loadChatHistory() to check for active project before fetching all sessions - When active project exists, use project.sessions instead of fetching from API - Added detailed console logging to debug session filtering - This prevents ALL sessions from appearing in every project's sidebar Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
229
CACHE_BUSTING_FIX.md
Normal file
229
CACHE_BUSTING_FIX.md
Normal file
@@ -0,0 +1,229 @@
|
||||
# Browser Cache-Busting Fix - Implementation Summary
|
||||
|
||||
## Problem
|
||||
Browsers were caching old JavaScript files and ignoring cache headers. The file `/home/uroma/obsidian-web-interface/public/claude-ide/ide.js` had been fixed (regex at line 494), but browsers kept loading the old broken version.
|
||||
|
||||
## Root Cause
|
||||
1. Inconsistent cache-busting parameters in HTML (ide.js used `?t=` while others used `?v=`)
|
||||
2. Stale timestamps (ide.js had `1769008200000` vs `1769008667735` for other files)
|
||||
3. HTML files were not included in Express cache-busting logic
|
||||
4. Outdated inline cache-busting script in HTML head
|
||||
|
||||
## Solution Implemented
|
||||
|
||||
### 1. Updated HTML File (`/home/uroma/obsidian-web-interface/public/claude-ide/index.html`)
|
||||
|
||||
**Changes:**
|
||||
- Unified all asset references to use `?v=` parameter (not `?t=`)
|
||||
- Applied fresh timestamp `1769008703817` to all JavaScript and CSS files
|
||||
- Removed outdated inline cache-busting script (lines 9-19)
|
||||
- Added cache-busting meta tags:
|
||||
```html
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Expires" content="0">
|
||||
```
|
||||
|
||||
**Files Updated:**
|
||||
- All 14 JavaScript files now have `?v=1769008703817`
|
||||
- All 11 CSS files now have `?v=1769008703817`
|
||||
|
||||
**Critical Fix:**
|
||||
```html
|
||||
<!-- Before -->
|
||||
<script src="/claude/claude-ide/ide.js?t=1769008200000"></script>
|
||||
|
||||
<!-- After -->
|
||||
<script src="/claude/claude-ide/ide.js?v=1769008703817"></script>
|
||||
```
|
||||
|
||||
### 2. Updated Server Configuration (`/home/uroma/obsidian-web-interface/server.js`)
|
||||
|
||||
**Changes:**
|
||||
- Added HTML files to cache-busting logic (line 374)
|
||||
- Updated comments to reflect HTML inclusion (lines 367, 373)
|
||||
|
||||
**Before:**
|
||||
```javascript
|
||||
if (filePath.endsWith('.js') || filePath.endsWith('.css')) {
|
||||
```
|
||||
|
||||
**After:**
|
||||
```javascript
|
||||
if (filePath.endsWith('.js') || filePath.endsWith('.css') || filePath.endsWith('.html')) {
|
||||
```
|
||||
|
||||
### 3. Cache-Busting Infrastructure
|
||||
|
||||
**Existing Components (Verified):**
|
||||
- `/home/uroma/obsidian-web-interface/cache-bust-middleware.js` - Dynamic asset versioning
|
||||
- Server uses `createCacheBustingMiddleware(ASSET_VERSION)` at line 242
|
||||
- Static file serving has:
|
||||
- `etag: false`
|
||||
- `lastModified: false`
|
||||
- Cache-Control headers for JS, CSS, and now HTML files
|
||||
|
||||
**Nginx Configuration (Verified):**
|
||||
```nginx
|
||||
location /claude {
|
||||
proxy_pass http://127.0.0.1:3010;
|
||||
proxy_hide_header Cache-Control;
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0" always;
|
||||
add_header Pragma "no-cache" always;
|
||||
add_header Expires "0" always;
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Automation Script
|
||||
|
||||
Created `/home/uroma/obsidian-web-interface/force-cache-refresh.sh`:
|
||||
- Generates fresh timestamp
|
||||
- Updates all asset references in HTML
|
||||
- Creates backup
|
||||
- Restarts server
|
||||
- Verifies server status
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
./force-cache-refresh.sh
|
||||
```
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### Cache-Busting Strategy
|
||||
|
||||
1. **Query Parameter Approach**: All assets use `?v=TIMESTAMP` format
|
||||
2. **Timestamp Generation**: `Date.now()` in milliseconds (e.g., `1769008703817`)
|
||||
3. **Scope**: Applied to all JavaScript, CSS, and HTML files
|
||||
4. **Layered Defense**:
|
||||
- Meta tags in HTML head
|
||||
- HTTP headers from Express
|
||||
- HTTP headers from Nginx
|
||||
- Dynamic query parameters
|
||||
|
||||
### Headers Applied
|
||||
|
||||
**Express Server:**
|
||||
```
|
||||
Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0
|
||||
Pragma: no-cache
|
||||
Expires: 0
|
||||
ETag: (disabled)
|
||||
```
|
||||
|
||||
**Nginx Proxy:**
|
||||
```
|
||||
Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0
|
||||
Pragma: no-cache
|
||||
Expires: 0
|
||||
```
|
||||
|
||||
## Testing & Verification
|
||||
|
||||
### Manual Testing Steps:
|
||||
1. Clear browser cache (Ctrl+Shift+Delete)
|
||||
2. Hard refresh page (Ctrl+Shift+R)
|
||||
3. Open DevTools Network tab
|
||||
4. Verify all assets load with `?v=1769008703817`
|
||||
5. Check response headers show no-cache directives
|
||||
|
||||
### Server Status:
|
||||
```
|
||||
Process ID: 1074464
|
||||
Port: 3010
|
||||
Status: Listening
|
||||
Configuration: Active
|
||||
```
|
||||
|
||||
## Prevention of Future Issues
|
||||
|
||||
### Best Practices Implemented:
|
||||
1. **Consistent Parameter Naming**: All assets use `?v=` (not mixed with `?t=`)
|
||||
2. **Timestamp Synchronization**: All assets receive the same timestamp simultaneously
|
||||
3. **HTML Cache Protection**: HTML files now have no-cache headers
|
||||
4. **Automated Refresh**: Script available for future updates
|
||||
|
||||
### Development Workflow:
|
||||
1. Make code changes
|
||||
2. Run `./force-cache-refresh.sh`
|
||||
3. Hard refresh browser
|
||||
4. Verify changes load
|
||||
|
||||
## Files Modified
|
||||
|
||||
1. `/home/uroma/obsidian-web-interface/public/claude-ide/index.html`
|
||||
- Updated all script and link tags
|
||||
- Added meta tags
|
||||
- Removed inline script
|
||||
|
||||
2. `/home/uroma/obsidian-web-interface/server.js`
|
||||
- Added HTML to cache-busting logic
|
||||
- Updated comments
|
||||
|
||||
3. `/home/uroma/obsidian-web-interface/force-cache-refresh.sh` (new)
|
||||
- Automation script for cache refresh
|
||||
|
||||
4. `/home/uroma/obsidian-web-interface/CACHE_BUSTING_FIX.md` (new)
|
||||
- This documentation
|
||||
|
||||
## Verification Commands
|
||||
|
||||
```bash
|
||||
# Check server is running
|
||||
ps aux | grep "node server.js"
|
||||
|
||||
# Check port is listening
|
||||
netstat -tlnp | grep 3010
|
||||
|
||||
# Verify timestamp in HTML
|
||||
grep "\.js?v=" /home/uroma/obsidian-web-interface/public/claude-ide/index.html
|
||||
|
||||
# Check server logs
|
||||
tail -20 /home/uroma/obsidian-web-interface/server.log
|
||||
|
||||
# Test cache headers
|
||||
curl -I https://rommark.dev/claude/claude-ide/ide.js?v=1769008703817
|
||||
```
|
||||
|
||||
## Success Criteria
|
||||
|
||||
- [x] All JavaScript files have consistent timestamp
|
||||
- [x] All CSS files have consistent timestamp
|
||||
- [x] HTML files have cache-busting headers
|
||||
- [x] Nginx proxy has no-cache headers
|
||||
- [x] Express server has no-cache headers
|
||||
- [x] Server restarted and listening on port 3010
|
||||
- [x] Automation script created and executable
|
||||
- [x] Documentation created
|
||||
|
||||
## Expected Outcome
|
||||
|
||||
After this fix:
|
||||
1. Browsers will treat `ide.js?v=1769008703817` as a completely new resource
|
||||
2. Old cached version (`ide.js?t=1769008200000`) will not be used
|
||||
3. All browsers will download the fixed version with the regex at line 494
|
||||
4. Future changes can be deployed using the automation script
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If browsers still cache old content:
|
||||
1. Clear browser cache completely (Ctrl+Shift+Delete)
|
||||
2. Close all browser windows
|
||||
3. Restart browser
|
||||
4. Hard refresh (Ctrl+Shift+R)
|
||||
5. Check DevTools Network tab to verify new URLs are being requested
|
||||
6. Verify timestamp in HTML matches what you expect
|
||||
|
||||
## Maintenance
|
||||
|
||||
To update cache-busting timestamp in the future:
|
||||
```bash
|
||||
cd /home/uroma/obsidian-web-interface
|
||||
./force-cache-refresh.sh
|
||||
```
|
||||
|
||||
This will:
|
||||
- Generate a new timestamp
|
||||
- Update all asset references
|
||||
- Restart the server
|
||||
- Provide verification feedback
|
||||
Reference in New Issue
Block a user