Added Cache-Control headers for CSS/JS assets (#241)#1124
Added Cache-Control headers for CSS/JS assets (#241)#1124audiodude merged 1 commit intoopenzim:mainfrom
Conversation
Add cache.conf to nginx config to serve CSS and JS assets with proper Cache-Control headers, allowing browsers to cache them for 1 year. Follows same pattern as existing gzip.conf. Fixes openzim#241
|
What made you decide on 1 year? We don't release WP1 every week, but definitely up to a couple of times a month during busy periods. |
|
Vite generates content-hashed filenames by default (e.g. index-Abc123.js) with no custom assetFileNames or chunkFileNames configured in vite.config.js. This means cached files are automatically invalidated on each new release when the hash changes, making 1 year + immutable safe here. That said, happy to shorten to 1w or 1m if you prefer a more conservative approach regardless. |
Thanks for the explanation, that makes sense. Since the file names are unique to each release, we could theoretically cache indefinitely, with no expiration, right? Either way this is fine, thanks! |
|
Exactly — with content-hashed filenames, indefinite caching is theoretically valid. I'll keep it at 1 year as a reasonable convention. Thanks for the review! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1124 +/- ##
=======================================
Coverage 92.78% 92.78%
=======================================
Files 74 74
Lines 4312 4312
=======================================
Hits 4001 4001
Misses 311 311 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Added cache.conf to nginx config to serve CSS and JS assets with
proper Cache-Control headers, allowing browsers to cache them
for 1 year. Follows same pattern as existing gzip.conf.
Fixes #241