Skip to main content
Version: v2.x

Enable GraphQL Caching


To start using Hasura Caching with your Hasura Enterprise Edition GraphQL Engine you will need a Redis instance that is co-located with the Hasura GraphQL containers.

Once you provision a Redis instance, provide the URL to the Hasura GraphQL Engine docker configuration using the following environment variable:

HASURA_GRAPHQL_REDIS_URL=redis://username:[email protected]:port

Enable Redis TLS

TLS connection information can be specified via the following environment variables:

  • HASURA_GRAPHQL_REDIS_USE_TLS: Opt-in flag that enables the use of TLS for the caching Redis instance, defaults to false.
  • HASURA_GRAPHQL_RATE_LIMIT_REDIS_USE_TLS: Opt-in flag that enables the use of TLS for the rate-limiting Redis instance, defaults to false.
  • HASURA_GRAPHQL_REDIS_TLS_HOSTNAME: TLS hostname to use for caching Redis instance.
  • HASURA_GRAPHQL_RATE_LIMIT_REDIS_TLS_HOSTNAME: TLS hostname to use for rate-limiting Redis instance.
  • HASURA_GRAPHQL_REDIS_TLS_SHARED_CA_STORE_PATH: path to the shared CA certificate store to use for both the caching and rate-limiting Redis instances. If unspecified, it defaults to the system CA store if available.


HASURA_GRAPHQL_REDIS_URL="redis://username:[email protected]:port"

For rate limit Redis:

HASURA_GRAPHQL_RATE_LIMIT_REDIS_URL="redis://username:[email protected]:port"

Tune caching parameters

You can tune the various caching parameters according to your use-case. For example, you can configure the maximum TTL allowed, the max entry size in the cache etc.

Env varFlagDescription
HASURA_GRAPHQL_CACHE_MAX_ENTRY_TTL--query-cache-max-ttlMaximum TTL allowed in seconds. Clients can request TTL via the @cached directive. But an upper limit can be set using this setting. Default: 600 seconds
HASURA_GRAPHQL_CACHE_MAX_ENTRY_SIZE--query-cache-max-entry-sizeMaximum size of the response that is allowed to be cached (in MB). default: 1 MB
HASURA_GRAPHQL_CACHE_BUCKET_RATE--query-cache-bucket-rateRecharge rate for the Query Response Cache token bucket. Default: 100,000 bytes/second
HASURA_GRAPHQL_CACHE_BUCKET_SIZE--query-cache-bucket-sizeMaximum capacity in bytes for the Query Response Cache token bucket algorithm. See for more info. Default: 10000000000 bytes (1gb)