Documentation
Gateway
Other Features
Performance/Cache
Upstream HTTP Caching

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 under the hood.

💡

You need to set your cache storage in your gateway configuration to enable response caching. See Cache Storage for more information.

gateway.config.ts
import { defineConfig, useHttpCache } from '@graphql-hive/gateway'
 
export const gatewayConfig = defineConfig({
  cache // Your cache storage here,
  plugins: pluginCtx => [
    useHttpCache({
      ...pluginCtx
    })
  ]
})