<link rel="stylesheet" href="main.css?hash=sha384-5rcfZgbOPW7..." integrity="sha384-5rcfZgbOPW7..."/>
Etag: "sha384-5rcfZgbOPW7..."
Cache-Control: max-age=31536000, immutableHow do you do version updates? Add content hash to all files except for root index.html.
Cache everything forever, except for index.html
To deploy new version upload all files, making sure index.html is last.
Since all files are unique, old version continues to be served.
No cache invalidating required since all files have unique paths, expect index.html which was never cached.
You have to ensure you absolutely have properly content hashes for everything. Images, css, js. Everything
For example cloudfront with s3, you use If-None-Match when uploading to ensure deploy fails on conflict
The build logic to decide which things to rebuild of course is probably the interesting bits but we dont need all these services... </grey-beard-rant>
[1] https://openbenchmarking.org/test/pts/nginx&eval=c18b8feaeca...
edit: to be less ranty they are more or less building static sites out of their Next.js codebase but on-demand updated etc which is indeed interesting but none of this needs cloudflare/hyerscaler tech
Not sure how many customers/sites they have. Perhaps they don't want to spend CPU regenerating all sites on every deployment? They do describe a content-driven pre-warmer but I'm still unclear why this couldn't be a content-driven static site generator running on some build machine
I already had HAProxy setup. So I have added stale while revalidate compatible header from HAProxy. Cloudflare handle the rest.
Edit: I am not using vercel. Self hosted using docker on EC2.
I obviously can be done but clearly is not the intended solution which really bothers me
Now that I have proper header added by HAProxy, Cloudflare cache rules for stale-while-revalidate works.
If anyone can reach Cloudflare. Please let us forcefully use stale-while-revalidate even when upstream server tells otherwise.
I have come to conclude it is that way because they focus on optimizing for a demo case that presents well to non-technical stakeholders. Doing one particular thing that looks good at a glance gets the buy-in, and then those who bought in never have to deal with the consequences of the decision once it is time to build something other than the demo.
However, it's probably more inexperience than anything. Nobody senior was around to tell our founders that they should go for a SSG architecture when they started /shrug. It's mostly worked out anyways though haha.
“Incremental Static Regeneration” is also one of the funniest things to come out of this tech cycle.