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

Why no-cache? #101

Closed
kayx23 opened this issue Aug 1, 2023 · 2 comments
Closed

Why no-cache? #101

kayx23 opened this issue Aug 1, 2023 · 2 comments

Comments

@kayx23
Copy link

kayx23 commented Aug 1, 2023

Testing graphql caching in the downstream and found cache-control: no-store header in the response.

What was the consideration of not allowing caching for the queries and mutations?

function QueryResultDisplay(props: QueryResultDisplayProps): ReactElement {
const { query, variables } = props;
const result = useQuery(query, {
variables,
fetchPolicy: "no-cache",
});
return <OperationResultDisplay result={result} />;
}

@ealmansi
Copy link
Owner

ealmansi commented Aug 1, 2023

hi @kayx23,

on the topic of caching, from the Apollo Server docs:

by default, no operation results are cached unless you set cache hints

since this is a reference/educational project, keeping default behaviours is likely the best way to avoid confusion for beginners

as a side note: the code you linked is client code from the website itself; it does not prescribe the server's caching behaviour. aka: fetchPolicy: "no-cache" is not related to the API response containing the cache-control: no-store header

@kayx23
Copy link
Author

kayx23 commented Aug 1, 2023

This is clear. Thanks!

@kayx23 kayx23 closed this as completed Aug 1, 2023
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

No branches or pull requests

2 participants