Serve
Features
Performance/Cache
Upstream HTTP Caching

HTTP caching

💡

This page is currently under construction and expected to change. Please feel free to reach out to us directly in case you are having any troubles.

Most of JavaScript runtimes except browsers don’t respect HTTP caching headers by default. But you can enable HTTP caching in your GraphQL Mesh 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.

npm i @graphql-mesh/plugin-http-cache
💡

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

mesh.config.ts
import useHttpCache from '@graphql-mesh/plugin-http-cache'
 
export const serveConfig = {
  cache // Your cache storage here,
  plugins: pluginCtx => [
    useHttpCache({
      ...pluginCtx
    })
  ]
}