Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static JS and Images served under /static/ are not cached due to caching policy headers #2801

Open
nguyenmp opened this issue Nov 21, 2024 · 2 comments
Assignees
Labels

Comments

@nguyenmp
Copy link

nguyenmp commented Nov 21, 2024

Describe the bug
All the normal content I'd expect to be cached under /static/ have headers that prevent caching. Caching is prevented on browser and CDNs.

$ curl -v http://localhost/static/js/jquery-3.6.0.min.js -o /dev/null
...
< Cache-Control: no-cache, max-age=0
< Expires: Thu, 21 Nov 2024 21:58:06 GMT
...

Expires is set to the current time so both headers need to be fixed.

This was briefly mentioned in #2053 (comment) and the code is probably https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/flask_app.py#L1248, but it's not obvious to me what is setting this. Maybe it's default for flask because it assumes dynamic content by default?

Workaround: In Cloudflare, I can set up a specific Cache Rule for anything under /static/ to force a cache TTL header.

Version
Exact version in the top right area: v0.47.06

How did you install?

Docker: ghcr.io/dgtlmoon/changedetection.io

To Reproduce

Steps to reproduce the behavior:

  1. docker run -p "80:5000" ghcr.io/dgtlmoon/changedetection.io
  2. curl -v http://localhost/static/js/jquery-3.6.0.min.js -o /dev/null

Expected behavior
Static content should have a pretty long max-age cache and expiry.

@dgtlmoon
Copy link
Owner

hmm yeah, only exception is some stuff like screenshots (which shouldnt be under /static anyway i guess)

@dgtlmoon
Copy link
Owner

i read it may be due to the 'development' style web server, it needs to be wrapped with 'gunicorn' or similar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants