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

Follow-up from #6986 #7015

Merged
merged 1 commit into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/source/performance/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,7 @@ The effect of setting `honorSubgraphCacheControlHeader` to `false` is to have no

## Caching with a CDN

Whenever Apollo Server sends an operation response that is cacheable, it includes a `Cache-Control` HTTP header that describes the response's cache policy.

To be cacheable, all of the following must be true:
- The operation has a non-zero `maxAge`.
- The operation has a single response rather than an [incremental delivery](../workflow/requests#incremental-delivery-experimental) response.
- There are no errors in the response.
By default, Apollo Server sends a `Cache-Control` header with all responses that describes the response's cache policy.

When the response is cacheable, the header has this format:

Expand All @@ -346,6 +341,11 @@ Cache-Control: max-age=60, private

When the response is not cacheable, the header has the value `Cache-Control: no-store`.

To be cacheable, all of the following must be true:
- The operation has a non-zero `maxAge`.
- The operation has a single response rather than an [incremental delivery](../workflow/requests#incremental-delivery-experimental) response.
- There are no errors in the response.

If you run Apollo Server behind a CDN or another caching proxy, you can configure it to use this header's value to cache responses appropriately. See your CDN's documentation for details (for example, here's the [documentation for Amazon CloudFront](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html#expiration-individual-objects)).

Some CDNs require custom headers for caching or custom values in the `cache-control` header like `s-maxage`. You can configure your `ApolloServer` instance accordingly by telling the built-in cache control plugin to just calculate a policy without setting HTTP headers, and specifying your own [plugin](../integrations/plugins):
Expand Down
2 changes: 1 addition & 1 deletion packages/integration-testsuite/src/httpServerTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ export function defineIntegrationTestSuiteHttpServerTests(
});
});

it('cache-control not set without any hints', async () => {
it('cache-control set to no-store without any hints', async () => {
const app = await createApp({
schema,
});
Expand Down