# cacheControl on Query type

**URL:** https://community.apollographql.com/t/cachecontrol-on-query-type/8134
**Category:** Server
**Tags:** caching, server
**Created:** [January 22, 2025, 8:19pm UTC](https://community.apollographql.com/t/cachecontrol-on-query-type/8134 "2025-01-22T20:19:51Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Kheang\_Hok\_Chin](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/kheang_hok_chin/32/391_2.png) [@Kheang\_Hok\_Chin](https://community.apollographql.com/u/Kheang_Hok_Chin)
#### Post date: [January 22, 2025, 8:19pm UTC](https://community.apollographql.com/t/cachecontrol-on-query-type/8134/1 "2025-01-22T20:19:51Z")

</div>

Hi,

I was wondering, is there a way to put @cacheControl(maxAge: 60) on the Query type?

I know we can put it on individual fields but I don’t see an option to do it on the type Query.

The reasoning was to cache every root query without having to go through each one and put @cacheControl on it.

Thanks.

**UPDATE**

I found a solution, instead I used the defaultMaxAge plugin and it solved my issue.

---

<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: [January 27, 2025, 6:42pm UTC](https://community.apollographql.com/t/cachecontrol-on-query-type/8134/2 "2025-01-27T18:42:49Z")

</div>

> [@Kheang\_Hok\_Chin](#):
>
> I found a solution, instead I used the defaultMaxAge plugin and it solved my issue.

Thank you for sharing the update to your question. Yes that would be my reccomended solution as well: [Server-Side Caching - Apollo GraphQL Docs](https://www.apollographql.com/docs/apollo-server/performance/caching#setting-a-different-default-maxage)

But also you could always build your own directive to do custom features too. The static directive is quite simple in it’s code so you could make one yourself that could include the `QUERY` location: [Server-Side Caching - Apollo GraphQL Docs](https://www.apollographql.com/docs/apollo-server/performance/caching#in-your-schema-static)
