Cache Time to Live
  • 19 Jun 2024
  • 2 Minutes to read
  • PDF

Cache Time to Live

  • PDF

Article summary

Overview

The Cache Time to Live (TTL) rule lets you set caching policies to determine how long content is cached on the CDN before it is considered stale. The rule can also be configured to influence caching behavior on the client cache. Configuring Client TTL causes cache-control headers to be added to the response. You can configure a Cache Time To Live rule at the host or path level.

Note the following:

  • By default, the Cache TTL policies in the HTTP response from the origin override the Cache TTL policies defined by the rule.
  • By default, the Cache TTL policies specified by the rule are used ony when there is no Cache TTL policy specified in the response.
  • However, you can select the Origin Override setting so that the Cache TTL policies specified by the rule override any headers in the response related to Cache TTL.

Configure the Rule

Here, we'll describe how to configure the rule with the Delivery Service Management UI.

API Users may choose to build the site configuration offline.

To configure a Cache TTL rule:

  1. Navigate to the Select Rule dialog.

  2. In the Select Rule dialog, choose Cache Time to Live.

  3. Set the caching rules.
    Note that the caching rules are separately defined for both the CDN and the client to enable setting distinct Cache TTL policies.
    The following options are available under both CDN TTL and Client TTL:

    • TTL in Seconds: Used to specify the caching duration. Select TTL in seconds and then specify the caching duration (in seconds).
    • Obey Origin: Follows the TTL parameters defined in the HTTP response from the origin.
    • No Cache: Revalidates with the origin before serving the cached content.
    • No Stores: Sends all requests to the origin. Does not cache content.
  4. By default, the Cache TTL settings are applied only when there is no Cache TTL policy specified in the response from the origin server. To override the default, select Origin CDN/Client Override.

    When this parameter is set, if the response contains headers from the origin specifying Cache TTL, the rule settings will override them.

  5. Select Add Rule.


Examples

Example 1
In the following example, the TTL is set for a week, for both the CDN and client cache. The CDN TTL setting overrides any TTL settings in the origin response, while the Client TTL setting does not.
cacheTTL1.png



Example 2
In the following example, CDN TTL is set for a year with no origin override, while client TTL is not configured, defaulting to Obey Origin.
cacheTTL3.png



Example 3
In the following example, both the CDN and the client are directed to retrieve all content requests from the origin.
cacheTTL2.png

SVTA Component: MI.CachePolicy

When you save the configuration version, the MI.CachePolicy component is added to the JSON configuration.

In this example the MI.CachePolicy object sets the following Cache TTL behaviors. Note that "internal" represents the CDN TTL behavior, while "external" represents the Client TTL behavior.

{
	"generic-metadata-type": "MI.CachePolicy",
	"generic-metadata-value": {
		"force-external": false,
		"internal": "3600",
		"external": "as-is",
		"force-internal": true
  }
}


  • "internal": "3600" - The CDN TTL is set to 3600 seconds
  • "force-internal": true - The CDN TTL settings override any TTL settings in the origin response.
  • "force-external": false; "external": "as-is" - No client TTL behavior is specified.

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.