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

routing/http/server: add cache control #584

Merged
merged 6 commits into from
Mar 7, 2024
Merged

Conversation

hacdias
Copy link
Member

@hacdias hacdias commented Mar 5, 2024

Cache-control for ipfs/someguy#26.

@hacdias hacdias requested a review from a team as a code owner March 5, 2024 14:32
@hacdias hacdias force-pushed the http-routing-cache-control branch from 8028221 to 3d98596 Compare March 5, 2024 14:33
@hacdias hacdias requested a review from lidel March 5, 2024 14:33
@hacdias hacdias self-assigned this Mar 5, 2024
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 65.66%. Comparing base (97e347e) to head (3590def).

Impacted file tree graph

@@            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     
Files Coverage Δ
routing/http/types/json/responses.go 50.81% <100.00%> (+5.36%) ⬆️
routing/http/server/server.go 69.68% <89.47%> (+2.04%) ⬆️

... and 9 files with indirect coverage changes

CHANGELOG.md Outdated Show resolved Hide resolved
hacdias and others added 2 commits March 6, 2024 10:44
Co-authored-by: Daniel Norman <1992255+2color@users.noreply.github.com>
@hacdias hacdias force-pushed the http-routing-cache-control branch from 52243a2 to 2a18c58 Compare March 6, 2024 09:44
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.
Copy link
Member

@lidel lidel left a 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:

routing/http/server/server.go Show resolved Hide resolved
routing/http/server/server.go Show resolved Hide resolved
routing/http/server/server.go Show resolved Hide resolved
routing/http/server/server.go Show resolved Hide resolved
routing/http/server/server.go Outdated Show resolved Hide resolved
@hacdias hacdias merged commit b6b7771 into main Mar 7, 2024
13 checks passed
@hacdias hacdias deleted the http-routing-cache-control branch March 7, 2024 08:34
wenyue pushed a commit to wenyue/boxo that referenced this pull request Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: 🎉 Done
Development

Successfully merging this pull request may close these issues.

3 participants