- 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>
6.7 KiB
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
- Inconsistent cache-busting parameters in HTML (ide.js used
?t=while others used?v=) - Stale timestamps (ide.js had
1769008200000vs1769008667735for other files) - HTML files were not included in Express cache-busting logic
- 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
1769008703817to all JavaScript and CSS files - Removed outdated inline cache-busting script (lines 9-19)
- Added cache-busting meta tags:
<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:
<!-- 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:
if (filePath.endsWith('.js') || filePath.endsWith('.css')) {
After:
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: falselastModified: false- Cache-Control headers for JS, CSS, and now HTML files
Nginx Configuration (Verified):
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:
./force-cache-refresh.sh
Implementation Details
Cache-Busting Strategy
- Query Parameter Approach: All assets use
?v=TIMESTAMPformat - Timestamp Generation:
Date.now()in milliseconds (e.g.,1769008703817) - Scope: Applied to all JavaScript, CSS, and HTML files
- 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:
- Clear browser cache (Ctrl+Shift+Delete)
- Hard refresh page (Ctrl+Shift+R)
- Open DevTools Network tab
- Verify all assets load with
?v=1769008703817 - 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:
- Consistent Parameter Naming: All assets use
?v=(not mixed with?t=) - Timestamp Synchronization: All assets receive the same timestamp simultaneously
- HTML Cache Protection: HTML files now have no-cache headers
- Automated Refresh: Script available for future updates
Development Workflow:
- Make code changes
- Run
./force-cache-refresh.sh - Hard refresh browser
- Verify changes load
Files Modified
-
/home/uroma/obsidian-web-interface/public/claude-ide/index.html- Updated all script and link tags
- Added meta tags
- Removed inline script
-
/home/uroma/obsidian-web-interface/server.js- Added HTML to cache-busting logic
- Updated comments
-
/home/uroma/obsidian-web-interface/force-cache-refresh.sh(new)- Automation script for cache refresh
-
/home/uroma/obsidian-web-interface/CACHE_BUSTING_FIX.md(new)- This documentation
Verification Commands
# 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
- All JavaScript files have consistent timestamp
- All CSS files have consistent timestamp
- HTML files have cache-busting headers
- Nginx proxy has no-cache headers
- Express server has no-cache headers
- Server restarted and listening on port 3010
- Automation script created and executable
- Documentation created
Expected Outcome
After this fix:
- Browsers will treat
ide.js?v=1769008703817as a completely new resource - Old cached version (
ide.js?t=1769008200000) will not be used - All browsers will download the fixed version with the regex at line 494
- Future changes can be deployed using the automation script
Troubleshooting
If browsers still cache old content:
- Clear browser cache completely (Ctrl+Shift+Delete)
- Close all browser windows
- Restart browser
- Hard refresh (Ctrl+Shift+R)
- Check DevTools Network tab to verify new URLs are being requested
- Verify timestamp in HTML matches what you expect
Maintenance
To update cache-busting timestamp in the future:
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