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

Entity Caching - Router can propagate unnecessary cache-control directives to client #6441

Open
FineAndDanD opened this issue Dec 11, 2024 · 1 comment · May be fixed by #6543
Open

Entity Caching - Router can propagate unnecessary cache-control directives to client #6441

FineAndDanD opened this issue Dec 11, 2024 · 1 comment · May be fixed by #6543

Comments

@FineAndDanD
Copy link

FineAndDanD commented Dec 11, 2024

Describe the bug

I encountered a situation where someone has a custom Java library that intercepts the response from a subgraph before it goes out to the router and inserts a cache-control header into that response.

The problem is:

  • With entity caching enabled it seems that it allows subgraphs to insert additional directives programmatically, but the router does not filter out unnecessary values, which is a confusing experience for clients.

The router does disallow invalid values and there does seem to be some logic to validate the directives present (ex. when passing no-cache it changes it in the final response to no_cache)

To Reproduce

  1. I've created a reproduction subgraph here, you'll need to clone it and run through the README: https://github.com/FineAndDanD/springboot-dgs-content-cache-repro
  2. I've also created a graph in Studio. I didn't want to expose the API key so please feel free to reach out if you want to avoid creating your own graph. Since this is an enterprise feature a graph ref and API key will be needed.
  3. Ensure you have a cache running with the basic entity caching router config from here: https://www.apollographql.com/docs/graphos/routing/performance/caching/entity#configure-router-for-entity-caching
  4. Start the subgraph, the cache and the router and send a request! I've added a screenshot of what you should see in the headers.

Expected behavior

The expected behaviour is that the router will filter out unnecessary values from the cache-control header when the request resolves. So if there's max-age=10, no-cache, must-revalidate, no-store, the expected value for the cache-control header would simply be no-store. Please see the MDN docs for justification of this reasoning: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#preventing_storing

Output

Screenshot 2024-12-11 at 2 06 34 PM

Desktop (please complete the following information):

  • OS: [e.g. iOS] MacOS
  • Version [e.g. 22] Sonoma 14.7

Additional context

N/A

@bnjjj bnjjj linked a pull request Jan 14, 2025 that will close this issue
6 tasks
@bnjjj
Copy link
Contributor

bnjjj commented Jan 14, 2025

Thanks @FineAndDanD for all the details and the reproduction steps. I was able to reproduce and I also added a unit test which is currently failing in our codebase. It will be prioritized in order to fix it properly

@abernix abernix changed the title Entity Caching - Router can propegate unnnecessary cache-control directives to client Entity Caching - Router can propagate unnecessary cache-control directives to client Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants