All Products
Search
Document Center

CDN:Serve stale content

Last Updated:Dec 17, 2025

The serve stale content feature is an important fault tolerance and availability measure in Alibaba Cloud CDN. If your origin server experiences issues, such as 4xx or 5xx errors or timeouts, CDN can continue to serve expired cached content from its nodes. This ensures that users can access your website even if the origin server is temporarily down, improving website availability and the user experience. This feature is not required for dynamic resource requests.

Use cases

Origin server failure or unavailability: If the origin server fails or becomes unavailable due to a server breakdown, network interruptions, or application errors, Alibaba Cloud CDN nodes cannot fetch the latest content.

  • If you do not enable the serve stale content feature, CDN nodes attempt to fetch content from the origin server when they receive a user request. If the origin server is down, the request fails, and users cannot access your website.

  • If you enable the serve stale content feature, CDN nodes can serve expired cached content to users even if the origin server is down. This ensures that your website remains accessible.

How it works

image

Procedure

  1. Log on to the CDN console.

  2. In the navigation pane on the left, click Domain Names.

  3. On the Domain Names page, find the domain name that you want to manage and click Manage in the Actions column.

  4. In the navigation pane on the left of the domain name, click Cache.

  5. Click the Serve Stale Content tab and then click Configure.

    image

    Parameter

    Required

    Default Value

    Description

    Honor Origin

    No

    Disabled. By default, the expiration extension time set in the serve stale content feature is used.

    If you enable Honor Origin and the origin server returns a file with the Cache-Control: stale-if-error=xx cache policy, CDN prioritizes the time set by the stale-if-error parameter as the cache expiration extension time.

    Origin Exception Status Code

    Optional

    By default, an origin error is defined as an origin response timeout or a 5xx status code response.

    Specifies the status codes returned by the origin server that trigger this feature. You can enter 4xx or 5xx for wildcard matching, or enter specific status codes like 502 or 504 for exact matching.

    You can enter multiple status codes. Separate them with commas.

    Extended Expiration Time

    Optional

    3,600 seconds (1 hour)

    The maximum time to retain the old cache after it expires. The minimum value is 1 second.

  6. Click OK.

FAQ

What is the difference between the "Status code TTL" and "Serve stale content" features?

Status code TTL and Serve stale content are both cache optimization features provided by Alibaba Cloud CDN. However, they differ in their trigger conditions, cached content, purpose, and configuration methods. The status code TTL feature is mainly used to cache responses with specific status codes to reduce requests to the origin server. The serve stale content feature is used to serve expired content during origin server failures to improve availability. Choose the feature that best suits your business needs and scenario to optimize website performance and user experience.

Difference

Status Code TTL

Serve Stale Content

Trigger

The expiration time of status code feature caches responses for specific HTTP status codes returned by the origin server.

The serve stale content feature is triggered when the origin server fails, times out, or returns a specific error status code.

Cached content

The expiration time of status code feature caches the origin server's response for a specific status code, such as a 404 page.

The serve stale content feature uses expired content that is already stored on Alibaba Cloud CDN nodes. This can be any type of resource.

Purpose

The purpose of the expiration time of status code feature is to reduce the number of requests to the origin server, reduce the load on the origin server, and speed up response times.

The purpose of the serve stale content feature is to improve website availability and the user experience by serving expired content if the origin server is down.

Configuration method

The expiration time of status code is typically configured separately in Alibaba Cloud CDN cache settings for specific HTTP status codes.

The serve stale content feature is typically implemented by setting a time-to-live (TTL) and enabling the feature.

To summarize, configure the "Serve stale content" feature if your origin server encounters errors, such as origin fetch timeouts or 5xx/4xx status codes. This feature is ideal for handling origin server failures and improving availability and the user experience. The "Expiration time of status code" feature is more suitable for caching specific HTTP status codes, such as 404 or 500, to improve response speed and reduce the load on the origin server. Its role during an origin server failure is relatively limited. You can configure one or both features as needed to achieve optimal performance and availability.

Note that you must set appropriate cache times and rules based on your business needs and website architecture. A TTL that is too long can prevent users from promptly receiving the latest content. A TTL that is too short may not effectively reduce the load on your origin server.