We architected an edge caching layer to eliminate cold starts
Posted by skeptrune 1 day ago
Comments
Comment by infogulch 22 hours ago
<link rel="stylesheet" href="main.css?hash=sha384-5rcfZgbOPW7..." integrity="sha384-5rcfZgbOPW7..."/>
Etag: "sha384-5rcfZgbOPW7..."
Cache-Control: max-age=31536000, immutableComment by rob74 21 hours ago
Comment by skeptrune 21 hours ago
Comment by infogulch 6 hours ago
Comment by pyrolistical 21 hours ago
How 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
Comment by Borealid 20 hours ago
Comment by pyrolistical 20 hours ago
For example cloudfront with s3, you use If-None-Match when uploading to ensure deploy fails on conflict
Comment by immibis 13 hours ago
Comment by owenthejumper 1 day ago
Comment by skeptrune 23 hours ago
Comment by 0x3f 1 day ago
Comment by amichal 1 day ago
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
Comment by 0x3f 1 day ago
Comment by SkiFire13 14 hours ago
Comment by cloudflare728 1 day ago
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.
Comment by amichal 21 hours ago
I obviously can be done but clearly is not the intended solution which really bothers me
Comment by 0x3f 1 day ago
Comment by cloudflare728 1 day ago
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.
Comment by amichal 1 day ago
Comment by skeptrune 1 day ago
Comment by 9rx 1 day ago
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.
Comment by 0x3f 23 hours ago
Comment by skeptrune 1 day ago
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.
Comment by immibis 13 hours ago
Comment by 0x3f 4 hours ago
Comment by samdoesnothing 22 hours ago
Comment by ricardobeat 23 hours ago
“Incremental Static Regeneration” is also one of the funniest things to come out of this tech cycle.
Comment by skeptrune 23 hours ago