Skip to content

Added Cache-Control headers for CSS/JS assets (#241)#1124

Merged
audiodude merged 1 commit intoopenzim:mainfrom
its-me-maady:fix/cache-control-headers
Mar 22, 2026
Merged

Added Cache-Control headers for CSS/JS assets (#241)#1124
audiodude merged 1 commit intoopenzim:mainfrom
its-me-maady:fix/cache-control-headers

Conversation

@its-me-maady
Copy link
Contributor

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

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
@its-me-maady its-me-maady changed the title Add Cache-Control headers for CSS/JS assets (#241) Added Cache-Control headers for CSS/JS assets (#241) Mar 22, 2026
@audiodude
Copy link
Member

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.

@its-me-maady
Copy link
Contributor Author

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.

@audiodude
Copy link
Member

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!

@its-me-maady
Copy link
Contributor Author

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
Copy link

codecov bot commented Mar 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.78%. Comparing base (6595be3) to head (6631b70).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@audiodude audiodude merged commit 60e2aee into openzim:main Mar 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Css/js resources should be cached in browser

2 participants