When running Zuplo on Akamai Connected Cloud, your API Gateway can control how
the Akamai CDN caches responses by setting the Cache-Control header. This
allows you to optimize caching behavior for different endpoints without
modifying Akamai Property Manager configurations.
How Akamai caching works
Akamai's CDN can cache responses at edge servers to reduce load to your Zuplo API Gateway and improve response times for clients.
When a request arrives, Akamai checks if a cached response exists. On a cache miss, the request goes to Zuplo, which can set cache headers on the response. Akamai caches the response according to those headers and serves subsequent requests directly from the edge cache.
The CDN determines caching behavior based on:
- Akamai Property Manager settings - Default caching rules configured in your CDN property
- Origin response headers - Headers sent by Zuplo that can override or influence default behavior
When your Akamai property is configured to "Honor origin Cache-Control and Expires" headers, Zuplo can control caching behavior on a per-response basis.
For complete details on Akamai's caching behavior, see the Akamai caching documentation.
Cache-Control header
The Cache-Control header controls caching for both the CDN and downstream
clients (browsers). Akamai honors the following directives when configured to
respect origin headers:
| Directive | Description |
|---|---|
max-age | Cache duration for browsers and downstream caches (seconds) |
s-maxage | Cache duration for shared caches like CDNs (seconds) |
no-cache | Revalidate with origin before serving cached content |
no-store | Don't cache the response at all |
private | Only allow browser caching, not CDN caching |
public | Allow caching by CDNs and browsers |
must-revalidate | Must revalidate after max-age expires |
Using s-maxage for CDN caching
The s-maxage directive is specifically for shared caches like CDNs. When both
max-age and s-maxage are present, Akamai uses s-maxage for edge caching
and forwards max-age to browsers:
Code
This example caches content at the CDN for 1 hour while instructing browsers to cache for only 1 minute.
Common Cache-Control patterns
| Scenario | Header Value |
|---|---|
| CDN: 1 hour, Browser: none | Cache-Control: public, s-maxage=3600, max-age=0 |
| CDN: 1 day, Browser: 5 min | Cache-Control: public, s-maxage=86400, max-age=300 |
| No caching | Cache-Control: no-store |
| Browser only, no CDN | Cache-Control: private, max-age=3600 |
Setting cache headers in Zuplo
Using the Set Headers policy
The simplest way to add cache headers is using the Set Headers Outbound Policy:
config/policies.json
This configuration caches responses at the CDN for 1 hour while allowing browsers to cache for only 1 minute.
Using custom code
For dynamic cache control based on response content or status, use a custom outbound policy:
modules/cache-control.ts
Downstream cacheability
By default, Akamai sends the smaller of the origin's Cache-Control max-age and
the remaining edge cache lifetime to clients. This ensures browsers don't cache
content longer than it remains valid at the edge.
You can control downstream (client) caching independently using Property Manager
settings or by setting explicit max-age values in your Cache-Control header.
For more information, see Akamai's downstream cacheability documentation.
Best practices
- Use s-maxage for CDN caching - Separate CDN and browser cache durations for better control
- Don't cache authenticated responses - Use
privateorno-storefor user-specific data - Set appropriate Vary headers - If responses vary by header (like
Accept-Language), include aVaryheader
Akamai Property Manager configuration
For Zuplo to control caching via headers, ensure your Akamai CDN property is configured to honor origin headers:
- In Property Manager, navigate to your property's caching behavior
- Set Caching Option to "Honor origin Cache-Control and Expires"
- Enable the Cache-Control directives you want to honor (max-age, s-maxage, etc.)
- Set a Default Max-age as a fallback when origin headers are missing
For detailed CDN setup instructions, see Setting up Akamai CDNs.
Related resources
- Set Headers Policy - Add headers to responses
- Caching Policy - Zuplo's built-in response caching
- Akamai Caching Documentation - Complete Akamai caching reference