fix(cache): FINAL FIX - prevent caching at Express level

Modified Express static file middleware to exclude admin files from caching.

Root cause: Express was setting aggressive 1-year cache headers for ALL .js files.
Nginx changes alone weren't sufficient because Express overrides them when proxying.

Three-layer solution:
1. Service Worker (v0.1.2): NEVER cache /js/admin/, /api/, /admin/
2. Express Middleware: no-cache headers for admin paths BEFORE general JS caching
3. Nginx: Prefix match location block for /js/admin/ with no-cache headers

This ensures NO level of the stack caches admin files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
TheFlow 2025-10-24 18:40:49 +13:00
parent 6aed0dd275
commit c01b08ef1b

View file

@ -95,6 +95,12 @@ app.use((req, res, next) => {
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0');
res.setHeader('Pragma', 'no-cache');
}
// Admin JS/HTML files: NEVER cache (always fetch fresh)
else if (path.startsWith('/js/admin/') || path.startsWith('/admin/')) {
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
res.setHeader('Pragma', 'no-cache');
res.setHeader('Expires', '0');
}
// CSS and JS files: Longer cache (we use version parameters)
else if (path.endsWith('.css') || path.endsWith('.js')) {
res.setHeader('Cache-Control', 'public, max-age=31536000, immutable'); // 1 year