Skip to content

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

Open
@nguyenmp

Description

@nguyenmp

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.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions