Add option to disable GET request cache#3
Merged
Conversation
trevor-scheer
approved these changes
Aug 19, 2022
Contributor
|
Tests and prettier passing locally, going to merge and double check when it lands. Classic "Circle sometimes doesn't run on forks" 🥳 |
Merged
trevor-scheer
pushed a commit
that referenced
this pull request
Aug 22, 2022
Rename property for RESTDataSource from requestCacheEnabled to memoizeGetRequests From the initial PR, the name of the new property was a little confusing since there are actually two caches, but what is being cached is the response data in the end. Original PR #3 Back-port of apollographql/apollo-server#6834
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Back-port from Apollo Server 3 repo: apollographql/apollo-server#6650
Fixes apollographql/apollo-server#6603
By default,
RESTDataSourcecaches all outgoing GET requests in a separate memoized cache from the regular response cache. It makes the assumption that all responses from HTTP GET calls are cacheable by their URL.If a request is made with the same cache key (URL by default) but with an HTTP method other than GET, the cached request is then cleared.
This change adds a new class property
requestCacheEnabled(which defaults totrueto match current behavior) which allows users to disable the cache. You might want to do this if your API is not actually cacheable or your data changes over time.Separately it documents this feature exists and adds more info about how to set a TTL for the entire HTTP cache