-
Notifications
You must be signed in to change notification settings - Fork 96
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
routing/http/server: add cache control #584
Conversation
8028221
to
3d98596
Compare
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## main #584 +/- ##
==========================================
+ Coverage 65.64% 65.66% +0.02%
==========================================
Files 207 207
Lines 25617 25656 +39
==========================================
+ Hits 16815 16848 +33
- Misses 7328 7335 +7
+ Partials 1474 1473 -1
|
Co-authored-by: Daniel Norman <1992255+2color@users.noreply.github.com>
52243a2
to
2a18c58
Compare
While we are at adding cache-control, we should leverage stale-while-revalidate hint, especially when we have useful results. Adding Last-Modified also does not cost us anything, but allows clients to benefit from caching proxies and CDNs in front of someguy returning HTTP 304 when request includes If-Modified-Since.
IPNS records should have "string etag" following syntax from https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
this ensures proxies put in front of someguy will use Accept from request in the cache key, and not mix application/x-ndjson responses with application/json ones.
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.
lgtm.
@hacdias i've pushed a few additional improvements which felt like low hanging fruits that will improve setups like our someguy deployment at https://delegated-ipfs.dev/routing/v1/, so would be good if you 👀 before merging.
If no concerns, feel free to merge and:
- bubble this up to someguy and delegated-ipfs
- PR against https://specs.ipfs.tech/routing/http-routing-v1/ ensure each endpoint has "response headers" documented (I think no need for IPIP, cache-control was just missing entierely)
Cache-control for ipfs/someguy#26.