Edit in GitHubLog an issue

Caching

API Mesh for Adobe Developer App Builder, uses dynamic content caching, which provides the following benefits:

  • Reduced load on your sources
  • Reduced latency and network hops
  • Reduced bandwidth consumption
  • Improved mesh performance
  • Improved load times
  • Simplified architecture (native caching only)

If you want to cache API Mesh responses, you have two options:

Regardless of the option you choose, you can configure your cache-control headers to control how long a response is cached.

Caching requirements

For API Mesh to cache a response, the request and response must meet the following requirements:

Request

  • The request method must be GET or POST.
  • The request must be a query operation type.
  • The request must not be an introspection query.

Response

Compliance

When considering PCI or HIPPA compliance as it relates to caching, you should understand the following:

  • API Mesh caching is disabled by default.
    • You must opt in to caching, by configuring meshConfig.responseConfig.cache: true.
  • When caching is configured, API Mesh acts as a public cache driven by cache-control headers returned from your sources.
  • API Mesh is a gateway and is unaware of the compliance requirements of your sources. You should understand your sources and ensure they return appropriate cache-control headers to prevent caching of sensitive data.

Source-driven caching

API Mesh implements a source-driven caching model. Your data sources are responsible for directing caching behavior by returning appropriate cache-control headers.

The mesh will respect and forward these cache directives at the mesh level, but your sources must ensure proper caching behavior for personalized content through appropriate header settings and cache control mechanisms.

Enable native caching

API Mesh supports dynamic content caching natively using standard HTTP caching.

To enable caching in API Mesh, add "cache": true to your responseConfig in your mesh configuration file. Caching is disabled by default.

Copied to your clipboard
{
"meshConfig": {
"sources": [
{
"name": "Adobe Commerce",
"handler": {
"graphql": {
"endpoint": "https://venia.magento.com/graphql"
}
}
}
],
"responseConfig": {
"includeHTTPDetails": true,
"cache": true
}
}
}

You should purge your cache every time you update your mesh configuration, if the changes could impact the cache.

Verifying the caching behavior using response headers

You can verify the caching behavior of GraphQL requests based on the values of the returned response headers when caching is enabled.

Response headers

The following response headers are returned when caching is enabled:

  • Age - On cache HIT, cached response age in seconds.

  • Cache-Status - HIT or MISS.

  • Etag - Unique identifier for a response.

  • Expires - UTC date when the cached response expires.

  • Last-Modified - UTC date when the cached response was stored.

Purge the cache

To purge your cache, use the following command.

Copied to your clipboard
aio api-mesh:cache:purge -a

Confirm that you want to purge the cache by selecting Yes. You can also auto confirm the purge by adding the --autoConfirmAction or -c flag.

Copied to your clipboard
aio api-mesh:cache:purge -a -c

For more information, refer to the Command reference.

Use your own CDN

While we recommend using the native API Mesh caching functionality, you can also provide your own content delivery network (CDN), such as Fastly. Refer to the Fastly caching example for more information.

To disable native caching in API Mesh and use your own CDN, ensure that your responseConfig contains "cache": false to avoid double caching.

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2025 Adobe. All rights reserved.