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

gateway: fix car/block responses cached as deserialized ones when ?format=raw|car is missing #606

Closed
lidel opened this issue Apr 17, 2024 · 0 comments · Fixed by #603
Closed
Labels
dif/expert Extensive knowledge (implications, ramifications) required effort/days Estimated to take multiple days, but less than a week P1 High: Likely tackled by core team if no one steps up topic/gateway Issues related to HTTP Gateway

Comments

@lidel
Copy link
Member

lidel commented Apr 17, 2024

Extracting context from internal https://github.com/orgs/ipshipyard/projects/1/views/1 to create a public log why Content-Location was added in #603

Problem

  • /ipfs/cid can return different bytes based on Accept header which caused bugs in the past (block response being returned instead of deserialized one etc)
    • We can't use Vary: Accept because we don't want cache key to be different for every blient/browser, we only want it to be different for block/car/ipns-record/tar/(dag-)json|cbor content types

Solution

  • Old bifrost-infra had custom code that uses custom cache key if response is block or car
    • Generic HTTP stack like LB from Cloudflare may not have that capability, and if it does, it requires custom config similar to one we did in Nginx.
    • Better to solve this at gateway level, using generic HTTP, with safe defaults that "just work" with stock HTTP tools and services, without requiring additional config on each deployment

Ideas

  • (A) Ensure unique URL per response type, so it does not matter if HTTP middleware is not aware of our content-types
    • Return HTTP 302 to ?format=car|raw|foo with Cache-Control: no-cache when alternative response format is requested
      • DOWNSIDE: bypasses http caches, hits backend every time (path needs to be resolved, blocks fetched/read)
  • (B)
  • (C) use Vary: Accept and pay the penalty of more cache misses

Plan

@lidel lidel added P1 High: Likely tackled by core team if no one steps up dif/expert Extensive knowledge (implications, ramifications) required effort/days Estimated to take multiple days, but less than a week topic/gateway Issues related to HTTP Gateway labels Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dif/expert Extensive knowledge (implications, ramifications) required effort/days Estimated to take multiple days, but less than a week P1 High: Likely tackled by core team if no one steps up topic/gateway Issues related to HTTP Gateway
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant