Skip to content

fix: correct no-store and no-cache behavior for entity cache#8952

Merged
carodewig merged 8 commits intodevfrom
caroline/router-1613/entity-cache
Mar 10, 2026
Merged

fix: correct no-store and no-cache behavior for entity cache#8952
carodewig merged 8 commits intodevfrom
caroline/router-1613/entity-cache

Conversation

@carodewig
Copy link
Copy Markdown
Contributor

@carodewig carodewig commented Mar 3, 2026

Confusingly, no-store and no-cache have different meanings. Per RFC 9111:

  • no-store: allows serving response from cache, but prohibits storing response in cache
  • no-cache: prohibits serving response from cache, but allows storing response in cache
    (NB: no-cache actually prohibits serving response from cache without revalidation - but the router doesn't distinguish between lookup and revalidation)

The entity caching plugin was incorrectly treating no-store as both 'no serving response from the cache' and 'no storing response in the cache.'

This PR fixes that behavior.


Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • PR description explains the motivation for the change and relevant context for reviewing
  • PR description links appropriate GitHub/Jira tickets (creating when necessary)
  • Changeset is included for user-facing changes
  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Metrics and logs are added3 and documented
  • Tests added and passing4
    • Unit tests
    • Integration tests
    • Manual tests, as necessary

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. A lot of (if not most) features benefit from built-in observability and debug-level logs. Please read this guidance on metrics best-practices.

  4. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@carodewig carodewig requested a review from a team as a code owner March 3, 2026 17:31
@apollo-librarian
Copy link
Copy Markdown
Contributor

apollo-librarian bot commented Mar 3, 2026

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 1a07ddc4aa30f6c8e149384a
Build Logs: View logs


✅ AI Style Review — No Changes Detected

No MDX files were changed in this pull request.

Review Log: View detailed log

This review is AI-generated. Please use common sense when accepting these suggestions, as they may not always be accurate or appropriate for your specific context.

@carodewig
Copy link
Copy Markdown
Contributor Author

Replaces #8951 whose git history I royally messed up

@carodewig carodewig enabled auto-merge (squash) March 3, 2026 17:33
Copy link
Copy Markdown
Contributor

@rohan-b99 rohan-b99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any tests around no-cache? From a quick search most of them seemed to only cover no-store

Comment on lines +642 to +644
CacheControl::new(request.subgraph_request.headers(), None).ok()
} else {
None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than use an option here, does it make sense to default to CacheControl::no_store? This is only based on other places in the code where that pattern seems to be used (apollo-router/src/plugins/response_cache/plugin.rs), so let me know if I'm missing something here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! I believe those other places are used for the response cache-control rather than the request - we should default to both cache and store on the request side

@carodewig
Copy link
Copy Markdown
Contributor Author

@rohan-b99 Added tests in 9020cff - good call out!

@carodewig carodewig merged commit d51761d into dev Mar 10, 2026
15 checks passed
@carodewig carodewig deleted the caroline/router-1613/entity-cache branch March 10, 2026 11:06
@abernix abernix mentioned this pull request Mar 31, 2026
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.

2 participants