@subsquid/graphql-server supports caching via additional flags. It is done on a per-query basis. The whole response is cached for a specified amount of time (maxAge).
Caching is disabled until --dumb-cache is set. When caching is enabled and the numeric flags are omitted, squid-graphql-server uses these defaults:
To enable caching when deploying to SQD Cloud, add the caching flags to the
serve:prod command definition at commands.json, then use that command to run the server in the deployment manifest. Cloud currently supports only in-memory cache.
For example, the snippets below deploy a GraphQL API server with a 100 MB in-memory cache, a 5 second entry TTL, and a 5 second response max age:
commands.json
squid.yaml
npx squid-graphql-server --help.
--dumb-cache <cache-type>
Enables caching with either in-memory or redis. For redis, set the Redis connection string in REDIS_URL. SQD Cloud deployments currently support only in-memory cache.
--dumb-cache-size <mb>
Maximum cache size in megabytes. Applies only to the in-memory cache. Default: 50.
--dumb-cache-max-age <ms>
Global response max age in milliseconds. It is passed to both cache implementations and controls the cache response max age. Default: 5000.
--dumb-cache-ttl <ms>
Time-to-live for in-memory cache entries. Entries become eligible for eviction when they have not been updated for this duration. Default: 5000.