Configuring caching of GraphQL requests
If your implementation makes many GraphQL requests in quick succession, you may want to cache GraphQL requests (request throttling) in a small in-memory cache in order not to overwhelm the Public Content API and improve performance, while also keeping database connections down.
Procedure
- To enable the GraphQL request cache, ensure that the property graphql.request.caching.enabled in the
application.propertiesfile of the Content Service resolves totrue. - To configure the maximum amount of time, in milliseconds, between successive requests that is required for caching to kick in (defaults to 2000), ensure that the property graphql.request.caching.buffer.time resolves to the maximum number of milliseconds you want.
- To configure how many items to cache at any one time (defaults to 10), ensure that the property
graphql.request.caching.capacityresolves the maximum number of items you want to cache at any one time. - To configure the Time To Live (TTL), in seconds, for items in the cache (defaults to 60), ensure that the property
graphql.request.caching.ttlresolves to the TTL you want. It's recommend to keep this value low.