Open Ask AI (⌘/Ctrl+I)

Cache

You can add cache rules from your DX Cloud Cockpit. Caching reduces requests to Magnolia which helps reduce heavy processing loads and improves performance.

The options in the Cache section are not available to satellite clusters.

Serving stale content on origin failure is off by default. Contact support to enable it.

Subsections:

Select desired cluster

Select your desired cluster from the dropdown menu at the top of the Cockpit.

Select desired cluster in the Cockpit

Add Browser cache rule

browserCachePolicy is defined in Magnolia cache configuration. See Cache in DX Cloud Operations for background.

Rules:

  • The rules apply from top to bottom.
  • The first rule matching the request defines which Cache-Control header is applied to the response.
View from the Cockpit

Browser cache rule anatomy

To add a Browser cache rule:

  1. Go to your Cockpit.

  2. Go to CDN > Cache.

  3. Choose the Browser cache tab.

  4. Click Add policy.

    The new policy appears at the top of the policy list where you can edit it.

  5. Give the policy a Name.

  6. Choose the Type:

    TypeDescription
    Never cacheContent is never cached.
    Cache forSet how long content is cached (in minutes).
  7. Click Add voter if you want to add any voters.

  8. Choose the condition you want and click Add.

  9. Click Save.

  10. To put your rules into production, Publish your new rule.

    Your updates are not synced with Magnolia until you publish the policies. Published policies show the Synced with Magnolia label.

Add CDN cache rule

CDN caching controls the Surrogate-Control header. When the CDN sees this header, it uses it instead of Cache-Control, letting you give the browser and CDN different cache instructions.

For example, you might set Cache-Control: no-cache on images so browsers never cache them, while setting Surrogate-Control: max-age=31536000 so the CDN caches them for a year. If you need to update the images later, you only invalidate the CDN cache and all browsers immediately get the new version.

CDN caching also helps serve cached content when Magnolia is down or experiencing issues.

Rules:

  • The rules apply from top to bottom.
  • The first rule matching the request defines which Surrogate-Control header is applied to the response.
  • The Surrogate-Control header takes precedence over the Cache-Control header.
  • Surrogate-Control headers are removed before a response is sent to an end user.
  • In the absence of the Surrogate-Control header, the CDN uses the Cache-Control header.
View from the Cockpit

CDN cache rule anatomy

To add a CDN cache rule:

  1. Go to your Cockpit.

  2. Go to CDN > Cache.

  3. Choose the CDN cache tab.

  4. Click Add policy.

    The new policy appears at the top of the policy list where you can edit it.

  5. Give the policy a Name.

  6. Add a directive to the Surrogate Control field.

    What values can be added?

    • max-age: defines how long the response entity can be considered fresh in seconds before the cached entity is stale.
    • stale-while-revalidate: defines how long in seconds the cache can reuse a stale response while it revalidates it to the cache.
    • stale-if-error: when an error is encountered, a cached stale response can satisfy the request regardless of other freshness information. Unlike stale-while-revalidate, stale-if-error does not allow asynchronous revalidation.

    Example: max-age=86400, stale-while-revalidate=60

  7. Click Add voter if you want to add any voters.

  8. Choose the condition you want and click Add.

  9. Click Save.

  10. To put your rules into production, Publish your new rule.

    Your updates are not synced with Magnolia until you publish the policies. Published policies show the Synced with Magnolia label.

Restore cache versions

You can restore a previous version of a cache policy.

  1. Go to CDN > Cache.

  2. Choose your desired cache tab.

  3. Click Restore.

    A dropdown list of versions appears.

  4. Choose the version you want to restore.

  5. Click Restore.

Import cache policies

You can import cache policies from Magnolia.

  1. Go to CDN > Cache.

  2. Choose your desired cache tab.

  3. Click Import cache rules from Magnolia.

    The cache policies are imported and added to the list. You can edit the policies after the import.

Import conflicts

If you attempt to import cache policies that do not match the policies defined in Magnolia, you see a conflict error listing the conflicting policies including the name, value, and voters.

You can choose to use the local data or the Magnolia data directly from the Cockpit.

Import conflicts