Skip to content

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

Closed
mathew-cf wants to merge 1 commit into
ipfs:masterfrom
mathew-cf:root-cid-header
Closed

feat: Add X-IPFS-Root-CID header for faster cache invalidation#8617
mathew-cf wants to merge 1 commit into
ipfs:masterfrom
mathew-cf:root-cid-header

Conversation

@mathew-cf

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

ipfs-webui test is flaky. amending and pushing

@mathew-cf

Copy link
Copy Markdown
Contributor Author

tests still flaky. amending and pushing again

@Stebalien

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@lidel

lidel commented Feb 4, 2022

Copy link
Copy Markdown
Member

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

lidel commented Feb 7, 2022

Copy link
Copy Markdown
Member

@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