# Disabling cache in Apollo client when 'cache-control' response header is set with 'no-store'

**URL:** <https://community.apollographql.com/t/disabling-cache-in-apollo-client-when-cache-control-response-header-is-set-with-no-store/3230>\
**Category:** Client SDKs\
**Tags:** client, web\
**Created:** [April 5, 2022, 9:22pm UTC](https://community.apollographql.com/t/disabling-cache-in-apollo-client-when-cache-control-response-header-is-set-with-no-store/3230 "2022-04-05T21:22:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![saesbuba](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/saesbuba/32/2142_2.png) [@saesbuba](https://community.apollographql.com/u/saesbuba)\
**Post date:** [April 5, 2022, 9:22pm UTC](https://community.apollographql.com/t/disabling-cache-in-apollo-client-when-cache-control-response-header-is-set-with-no-store/3230/1 "2022-04-05T21:22:47Z")

</div>

Actually we are trying to add ‘cache-control’ response header from Apollo Server, but we would like to know how does Apollo Client behave when ‘cache-control’ is present in the response headers.

My question is, will Apollo Client automatically disable the cache when this header(cache-control) is present in the response headers with a value of ‘no-store’, or do I need to set up some configuration in the Apollo Client side for not allowing the cache when cache-control is equal to ‘no-store’?

---

<div class="post-metadata">

**Author:** ![shanemyrick](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/shanemyrick/32/5474_2.png) [@shanemyrick](https://community.apollographql.com/u/shanemyrick)\
**Post date:** [March 8, 2024, 9:36pm UTC](https://community.apollographql.com/t/disabling-cache-in-apollo-client-when-cache-control-response-header-is-set-with-no-store/3230/2 "2024-03-08T21:36:06Z")

</div>

The Apollo Client cache does not have a TTL cache currently so it does not support reading the `Cache-Control` headers as they commonly are returned with `cache-control max-age=60` to set a specific time.

If you would like to disable the cache for a particular operation you can set the fetch policy in Apollo Client: `fetchPolicy: 'no-cache'`

> **[Queries](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy)**
>
> Fetch data with the useQuery hook

---

<div class="post-metadata">

**Author:** ![Cr4DLe](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@Cr4DLe](https://community.apollographql.com/u/Cr4DLe)\
**Post date:** [March 15, 2024, 12:06pm UTC](https://community.apollographql.com/t/disabling-cache-in-apollo-client-when-cache-control-response-header-is-set-with-no-store/3230/3 "2024-03-15T12:06:36Z")

</div>

Thank @shanemyrick . We have tried with latest apollo/client (v3.9.7) which has a lot of memory improvements as @lenz [Apollo Client 3.9 Feature Spotlight – The memory story | Apollo GraphQL Blog](https://www.apollographql.com/blog/apollo-3-9-beta-feature-spotlight-the-memory-story)

We are using Apollo Client Devtools v4.8.1 to check what data is cached. We would like to confirm that only the “Cache” tab contains cache data. As we can see there is a section within “Queries” about cache data. Please see screenshot attached.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/6/6c322dc3de99f8fd1c0c5b49011a8a213dbaea2d.png)

We have created a very basic minimal repository for you to help us confirm the configuration to totally opt-out on queries, mutations, subscriptions is the expected configuration. [https://codesandbox.io/p/devbox/m4slm8?file=%2Fsrc%2Fgraphql%2FcreateApolloClient.ts%3A39%2C50-40%2C20&migrateFrom=7yx4hq](https://codesandbox.io/p/devbox/m4slm8?file=%2Fsrc%2Fgraphql%2FcreateApolloClient.ts%3A39%2C50-40%2C20&migrateFrom=7yx4hq)

Thank you for your time and great project contribution.

---

<div class="post-metadata">

**Author:** ![shanemyrick](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/shanemyrick/32/5474_2.png) [@shanemyrick](https://community.apollographql.com/u/shanemyrick)\
**Post date:** [March 18, 2024, 5:31pm UTC](https://community.apollographql.com/t/disabling-cache-in-apollo-client-when-cache-control-response-header-is-set-with-no-store/3230/4 "2024-03-18T17:31:20Z")

</div>

That config block matches the expected structure: [https://www.apollographql.com/docs/react/api/core/ApolloClient#example-defaultoptions-object](https://www.apollographql.com/docs/react/api/core/ApolloClient#example-defaultoptions-object)

---

<div class="post-metadata">

**Author:** ![Cr4DLe](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@Cr4DLe](https://community.apollographql.com/u/Cr4DLe)\
**Post date:** [March 19, 2024, 9:23am UTC](https://community.apollographql.com/t/disabling-cache-in-apollo-client-when-cache-control-response-header-is-set-with-no-store/3230/5 "2024-03-19T09:23:35Z")

</div>

Thank you @shanemyrick for confirming.

I understood that Apollo Chrome extension says “Cache Data” under queries but it is not really cached data. Do you think would be a good idea to rename it to something else?

One last question about caching subscription, as there is no way to say on the default options object, just to confirm that we need to include ‘fetchPolicy: “no-cache”’ in all subscription.

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![shanemyrick](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/shanemyrick/32/5474_2.png) [@shanemyrick](https://community.apollographql.com/u/shanemyrick)\
**Post date:** [March 19, 2024, 7:19pm UTC](https://community.apollographql.com/t/disabling-cache-in-apollo-client-when-cache-control-response-header-is-set-with-no-store/3230/6 "2024-03-19T19:19:16Z")

</div>

I am not on the client team, so if there is specific bug or issue you would like to raise, that can be done on our GitHub repo.

Does this issue reflect something that you are having issues with? If so feel free to add your comments there: [subscribeToMore not rerendering component when watchQuery's fetchPolicy is set to no-cache · Issue #8013 · apollographql/apollo-client · GitHub](https://github.com/apollographql/apollo-client/issues/8013)

---

<div class="post-metadata">

**Author:** ![jerelmiller](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/jerelmiller/32/3314_2.png) [@jerelmiller](https://community.apollographql.com/u/jerelmiller)\
**Post date:** [March 19, 2024, 7:59pm UTC](https://community.apollographql.com/t/disabling-cache-in-apollo-client-when-cache-control-response-header-is-set-with-no-store/3230/7 "2024-03-19T19:59:31Z")

</div>

Hey @Cr4DLe 👋

The cache tab in the devtools should only contain cached data. I’ve confirmed this includes the `Queries` tab as well.

Weird that you’re seeing something in the devtools. If I open your reproduction in its [own tab](https://m4slm8-5173.csb.app/), the devtools show that the query was made, but there is no cache data as expected. See my screenshots.

 ![Screenshot 2024-03-19 at 1.56.56 PM](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/9/9291d15d0df39f9fb26a1e206c072fd7f3e7abd1.png)  
 ![Screenshot 2024-03-19 at 1.56.50 PM](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/7/7522a21d7a2dfd646c278fb46cbc490c078a61f0.png)

If you’re not seeing this, could you open an issue in the [devtools repo](https://github.com/apollographql/apollo-client-devtools) so we can take a closer look?
