---
searchable: false
---

import { Callout } from '@theguild/components'

# HTTP caching

Most of JavaScript runtimes except browsers don't respect HTTP caching headers by default. But you
can enable HTTP caching in your Hive Gateway by using the HTTP caching plugin. This allows you to
cache the responses when possible, and reduce the server load. It uses
[`http-cache-semantics`](https://www.npmjs.com/package/http-cache-semantics) under the hood.

<Callout>
  You need to set your cache storage in your gateway configuration to enable response caching. See
  [Cache Storage](/docs/gateway/other-features/performance#providing-cache-storage) for more
  information.
</Callout>

```ts filename="gateway.config.ts"
import { defineConfig, useHttpCache } from '@graphql-hive/gateway'

export const gatewayConfig = defineConfig({
  cache // Your cache storage here,
  plugins: pluginCtx => [
    useHttpCache({
      ...pluginCtx
    })
  ]
})
```
