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

Add Cache-Control "public,max-age=0,must-revalidate" to index.html in SPA Example #410

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

d3473r
Copy link

@d3473r d3473r commented Jul 26, 2024

Edit the SPA example

Add the Cache-Control "public,max-age=0,must-revalidate" for index.html header to the SPA example.

In SPAs the index.html must be prevented from being cached, in the index.html the (fingerprinted) javascript and css file are referenced (these can be cached becaused they get a new random suffix everytime they are built)

… SPA example

Add the Cache-Control "public,max-age=0,must-revalidate" for index.html header to the SPA example.

In SPAs the index.html must be prevented from being cached, in the index.html the (hashed) javascript and css file are referenced (these can be cached becaused they get a new random suffix everytime they are built)
@mholt
Copy link
Member

mholt commented Jul 27, 2024

Is this strictly true for all SPAs? Mine work without this. The example here should be as minimal as possible, but in the new docs we can expand the examples.

@d3473r
Copy link
Author

d3473r commented Jul 28, 2024

Afaik as soon as you do try_files {path} /index.html you should explicitly set a cache-control index.html, see vercel vercel/serve#258, aws (they recommend 60 sec for index.html) https://aws.amazon.com/blogs/networking-and-content-delivery/host-single-page-applications-spa-with-tiered-ttls-on-cloudfront-and-s3/ or codecentric https://www.codecentric.de/wissens-hub/blog/deployment-configurable-single-page-application

But you are right, maybe a second example which talks about this issue would be better than modifying the minimal example.

One then could also add a long cache time (public,max-age=31536000,immutable) for css and js files as they are fingerprinted and have a different name when the application.is rebuild

Copy link
Member

@francislavoie francislavoie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Matt this should probably be a follow-up on the basic example rather than modifying the basic one.

src/docs/markdown/caddyfile/patterns.md Outdated Show resolved Hide resolved
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
@d3473r
Copy link
Author

d3473r commented Jul 28, 2024

Can you point me to the new docs, then i can add this example there

@mholt
Copy link
Member

mholt commented Jul 28, 2024

Oh I haven't got them ready yet. 😅 that's on me, I'm a bit behind lately.

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.

3 participants