-
Notifications
You must be signed in to change notification settings - Fork 285
whole response caching #326
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
Comments
Worth noting that one could break out "calculate a cache-control response header based on combining cache-control headers from subgraphs" as a smaller piece from actually implementing caching in the Router, if that's preferable. |
Big thumbs up for this one. It would be really beneficial to get some frequently used responses from the Apollo Router's cache when the actual data source is having some outages, or just to make the searches more efficient. If I understood right, that's what this feature would be for? For example, when building a client app with some SEO friendly server side rendered static pages, the data needs to be available and it would be nice to have it quickly for fast CI. |
uses cache-control headers from subgraphs to determine an overally cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overally cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overall cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overall cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overall cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overall cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overall cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overall cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overall cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overall cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overall cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overall cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overall cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overall cache-control policy partially addresses apollographql#326
uses cache-control headers from subgraphs to determine an overally cache-control policy partially addresses #326
uses cache-control headers from subgraphs to determine an overally cache-control policy partially addresses #326
Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action
For those following along we have released entity caching in Router 1.40.0: https://github.com/apollographql/router/releases/tag/v1.40.0 This is not whole response caching as implemented in the Gateway, it is actually more advanced and can still be used to cache response data |
If the schema's output type is a list (`[Type]`) but the response is not a list, this change wraps the response in a list as a convenience to the user. Without this change, the router's response formatting will silently drop the data. This is probably the right design choice because the Selection syntax is "agnostic" to arrays, so there's no way for the user to indicate how to handle this situation, nor is there a way to detect this situation during validation (at least not until we have a JSON spec to also validation against.)
Today, the Apollo Gateway supports whole response caching thanks to @mandiwise's contribution of apollographql/federation#870 as an evolution of the
@cacheControl
story in Apollo Server, which producescache-control
(andage
) headers.The PR above introduced the ability for the Gateway to synthesize a cache policy from
cache-control
headers of subgraphs and leverage Apollo Server's response cache plugin. In terms of implementation, this leverages uses Apollo Server'sresponseForOperation
plugin hook to short-circuit execution in the event of a cache-hit, and keys things using a cache key that is based on a hash of a variety of things includingvariables
,operationName
, etc. — as seen here.An analysis of the way things are done today should probably be drawn up as a design (or we should ask the Apollo Server team, or do some spelunking to see if a design already exists.)
All of this could be built on a key-value cache abstraction that supports either string in-memory, or in a distributed fashion (à la Memcached/Redis). Though that abstraction could be a separate issue (and also be used to implement other key-value stores that could also be, optionally, distributed, like APQ in #130)
And of course, we should consider any reports we want to sent to Studio, as was once requested in #1009. (See issue)
The text was updated successfully, but these errors were encountered: