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

feat: Add X-IPFS-Root-CID header for faster cache invalidation #8617

Closed
wants to merge 1 commit into from
Closed

feat: Add X-IPFS-Root-CID header for faster cache invalidation #8617

wants to merge 1 commit into from

Conversation

mathew-cf
Copy link
Contributor

If content resolution is performed separately from a go-ipfs node via DNS and/or IPNS, then the root CID can be used to check if a cached response is fresh or stale for a given path.

This allows quick cache invalidation once a change to a DNSLink record is propagated.

@mathew-cf
Copy link
Contributor Author

ipfs-webui test is flaky. amending and pushing

@mathew-cf
Copy link
Contributor Author

tests still flaky. amending and pushing again

@Stebalien
Copy link
Member

Note: If you're just caching, use the etag. It's the CID when downloading a file, and the CID plus a dir-index hash when indexing a directory.

(otherwise, it does seem reasonable to say "here's the CID of the thing I just resolved, but I'd just call it x-ipfs-cid in that case).

@mathew-cf
Copy link
Contributor Author

Basically the idea here is that I can use (mostly) DNS to resolve to a root CID at the edge. I can quickly cache and serve new data if I know whether my data currently in cache corresponds to the DNS record.

The resolved root CID is different from the CIDs of the files in the directory (i.e. the CID in the etag). I named the header x-ipfs-root-cid rather than x-ipfs-cid to try to make that clearer.

@mathew-cf
Copy link
Contributor Author

This wouldn't support IPFS subpaths. Needs some more thought

@lidel
Copy link
Member

lidel commented Feb 4, 2022

I understand the desire here is to have resolved IPNS root CID in the response?
Sounds good, but agree this needs more thought.

  • With the main Root CID + Etag you could do efficient invalidation of entire website every time IPNS mapping changes.
    • I think if we return all intermediate roots as well, that will enable more fine-grained cache invalidation at the path level – FYSA are looking into landing cache improvements like this – feel free to pitch in ideas/requests in Meta: HTTP Gateway cache control improvements #8717 🙏

@lidel
Copy link
Member

lidel commented Feb 7, 2022

@mathew-cf check #8720

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