-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat: X-Ipfs-Roots for smarter HTTP caches #8720
Conversation
This allows HTTP caches and CDNs make better decisions around cache invalidation: not only invalidate everything under IPNS website when the root changes, but also do partial invalidations when CID/block aware solutions are in place.
I didn't immediately understand why it's plural. In my head The way I think about it is that at any moment Your strategy here permits more granular cache invalidation, I am unsure if I could make use of it in nginx, but its good its there! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great caching change for paths that can be resolved to a CID by DNS
LGTM so far |
This documents the current behavior of mentioned headers. It helped to identify a a bug around index.html responses having etag of a dir-index-html (to be fixed in a separate change)
695fd17
to
8dce710
Compare
We were returning DirIndex Etag for every index.html response, which did not fully leverage our ability to maximize CID-based caching of HTML websites (every root document had invalid Etag). This fix replaces mutable DirIndex Etag with immutable one (of the dir that is a parent of index.html).
Pushed bunch of tests that document and protect the behavior around This is ready for final reviews / comments. If no concerns, the plan is to merge and ship this in go-ipfs 0.13. |
Taken from this PR: ipfs/kubo#8720 Bug desc. from PR text: fix a bug where we return DirIndex- Etag for index.html response (on EVERY WEBSITE EVER 🙈)
This PR adds
X-Ipfs-Roots
to Gateway responses.X-Ipfs-Roots
is a way to indicate all CIDs required for resolving path segments fromX-Ipfs-Path
– both headers are meant to improve interop with existing HTTP software (load-balancers, caches, CDNs).It allows HTTP caches and CDNs make better decisions around cache invalidation: not only invalidate everything under specific IPNS website when the root changes, but also do more fine-grained caching and content distribution when CID/block aware solutions are in place.
Rationale
X-Ipfs-Path
returned on mutable/ipns/
paths is not enough, and Gateway operator community raised the need for additional metadata to enable smarter cache.This is a low-hanging fruit from #8717 that can be shipped independently of other improvements.
Demo
Before
After
TODO
X-Ipfs-Roots
(all path CIDs folded into a single header)X-Ipfs-Roots
(new) andX-Ipfs-Path
(missing) andEtag
(missing)DirIndex-
Etag forindex.html
response (on EVERY WEBSITE EVER 🙈)