Configure GraphQL caching

By defining a registered API as a GraphQL API, you let clients use a defined query language that yields a more transparent and lightweight response. You can allow edge servers to identify GraphQL queries by defining the query and body parameters to interpret as indicators of GraphQL requests. You can also set up specific caching instructions for such requests.

Try the API: You can also complete this task by using the API Endpoints API. Run the Update GraphQL cache settings operation. Learn more about Akamai’s APIs.

Before you begin

Ensure that you defined a registered API as a GraphQL API by setting the GraphQL API switch on the API registration page to Yes.

How to

  1. On the API Definitions page, in the Registered APIs section, click the ellipsis icon () associated with the API configuration you want to configure GraphQL settings for.
  2. From the menu, select Manage versions.
  3. In the Version history panel, click the ellipsis icon () associated with the API configuration version you want to configure GraphQL settings for.
  4. From the list of delivery options, select GraphQL caching.
  5. On the GraphQL caching settings page, set the Enable GraphQL caching switch to Yes.
  6. In the Max age field, enter the maximum time for caching GraphQL responses.
    Note: You can specify this parameter in seconds, minutes, hours, or days. In each case, the value must be between 1 and 1000000.
  7. Optional: To honor your origin’s Cache-Control header settings, set the Honor origin Cache-Control switch to Yes.
    Edge servers can honor the following settings from the Cache-Control header to calculate GraphQL responses time-to-live (TTL): max-age, no-store, no-cache (behaves like setting a zero second max-age), pre-check (serves as a max-age setting if there is no max-age), post-check (serves as an edge prefresh settings). If your origin’s Cache-Control header does not specify a maximum age, API Gateway instead uses the value you entered in the Max age field.
  8. In the Query parameter name field, enter the name of the query parameter that indicates a GraphQL query in an incoming request.
  9. In the Body parameter name field, enter the name of the body parameter that indicates a GraphQL query in an incoming request.
  10. Optional: If you want edge servers to look for errors in a GraphQL response payload, set the Process response payload error handling switch to Yes.
  11. Optional: If you want edge servers to cache a GraphQL response if it contains errors, set the Cache response payload on error switch to Yes.
  12. In the Downstream cacheability section, from the Caching option menu, select the type of downstream caching that you want to implement.
    Downstream caching refers to the caching instructions that calling API clients should follow.
  13. Do one of these steps:
    If...Then...
    If you selected Allow caching, then do these steps:
    1. From the Cache lifetime menu, select the option for the maximum lifetime of cached objects.
    2. If you selected Fixed value in the previous step, in the Max age field, enter the maximum time for caching content.
      Note: You can specify this parameter in seconds, minutes, hours, or days. In each case, the value must be between 1 and 1000000.
    3. From the Send headers menu, select the type of headers that you want to send downstream.
    4. Optional: To disallow storing of HTTP responses in a shared cache, set the Mark as private switch to Yes.
    5. Click Save.
    If you selected Allow caching, require revalidation, then do these steps:
    1. Optional: To disallow storing of HTTP responses in a shared cache, set the Mark as private switch to Yes.
    2. Click Save.
    If you selected any other option, then click Save.