All Products
Document Center

CDN:What is caching?

Last Updated:Mar 22, 2024

When Alibaba Cloud CDN accelerates the delivery of static resources to a user, Alibaba Cloud CDN retrieves the resources from the origin server and caches the resources on the point of presence (POP) that is nearest to the user. When the resource is requested again, the POP directly returns the cached resource to the user without redirecting the request to the origin server. This accelerates content delivery. If the resource that is requested by the user does not exist on the POP or has expired, the POP initiates an origin fetch request to retrieve the latest data from the origin server.

Related features

The following table describes the operations that you can perform on a domain name by using the caching feature.



Create a cache rule for resources

Time-to-live (TTL) is the amount of time that a resource is cached on Alibaba Cloud CDN points of presence (POPs). When the TTL of a cached resource ends, the resource on the POPs expires. Requests that attempt to access expired resources are redirected to the origin server. The retrieved resources are returned to the clients and cached on the POPs. You can create a cache rule for static resources based on file directories or file name extensions.

Create a cache rule for HTTP status codes

When points of presence (POPs) retrieve resources from origin servers, the origin servers return HTTP status codes to the POPs. Alibaba Cloud CDN allows you to create cache rules for HTTP status codes. When clients request the same resource, the POPs return the status code instead of redirecting requests to the origin server. This reduces loads on origin servers. After a cached HTTP status code expires, requests that trigger the code are redirected to the origin server.

Create a status code expiration rule that honors origin

If you want to set the TTL for static content cached on Alibaba Cloud CDN points of presence (POPs) based on the status code returned from an origin server, you can create a cache rule for the status code that honors origin.

Configure an HTTP response header

HTTP response headers are a component of the header section in response messages that are transmitted over HTTP. HTTP response headers deliver specific parameters to clients to manage caching. You can configure HTTP response headers and allow Alibaba Cloud CDN to return the configured response headers. This way, specific features, such as cross-origin resource sharing (CORS), can be implemented.

Create a custom error page

After you create a custom error page, when the requested content does not exist or an error occurs, the point of presence (POP) returns the custom error page instead of the default error page. A custom error page improves user experience and allows users to view more user-friendly error prompts.

Create an access URL rewrite rule

If the directory of a resource on the origin server changes, the directory of the resource on points of presence (POPs) also changes. If the request URL to the resource does not change, POPs need to rewrite the request URL and redirect the request to the destination directory. This reduces the number of back-to-origin requests and improves client access performance.

Create custom cache keys

Allows you to set a cache key for a type of request that is destined for the same resource file. This can help you save the cache space and reduce the number of requests redirected to the origin server.

You can create rules to generate cache keys based on different parts of HTTP requests, such as URIs, request parameters, HTTP request headers, and custom variables. You can also use this feature to convert URLs for the same resource into the same cache key. This improves the cache hit ratio, and reduces the number of requests that are redirected to the origin server, response time, and bandwidth usage.

Configure cache sharing

After you configure cache sharing, accelerated domain names in the same Alibaba Cloud account can share resources that are cached on Alibaba Cloud CDN points of presence (POPs). If origin servers of different domain names store a large number of common resources, such as images, CSS files, and JavaScript files, you can configure cache sharing. This way, the domain names can share the common resources to reduce the bandwidth usage and increase the resource hit ratio for the domain names. This improves the acceleration performance of Alibaba Cloud CDN and reduces origin traffic.

Configure CORS

After you add your website to Alibaba Cloud CDN for content delivery, you can configure custom HTTP response headers to access resources from different origin servers.