What is caching?

更新时间:
复制 MD 格式

When Alibaba Cloud Dynamic Content Delivery Network (DCDN) accelerates the delivery of static resources to a user, DCDN 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. If the resource that is requested by the user does not exist on the POP or has expired, the POP retrieves the latest data from the origin server.

Caching features

DCDN supports the following caching features.

Feature

Description

Create a cache rule for resources

By configuring cache expiration rules, you can precisely control how long resources are cached on and DCDN POPs. This helps you balance content freshness, access performance, and origin fetch costs. This document covers how cache rules work, their configuration and verification, and relevant troubleshooting procedures and best practices.

Create a cache rule for HTTP status codes

When an Alibaba Cloud DCDN point of presence (POP) fetches a resource from your origin server, the origin server returns a response status code. You can configure a cache duration for these status codes in DCDN. When a client requests the same resource again, the DCDN POP returns the status code directly without performing an origin fetch. This reduces the load on your origin server. When the cache duration for the status code expires, a new origin fetch is triggered.

Configure HTTP response headers

The outgoing 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 outgoing response headers and allow DCDN 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, if the requested content does not exist or an error occurs, points of presence (POPs) return the custom error page instead of the default error page. This can improve user experience by providing users with user-friendly and functional error messages.

Create a URI rewrite rule

If a resource on the origin server is relocated, the URL of the resource that is cached on Dynamic Content Delivery Network (DCDN) points of presence (POPs) is accordingly adjusted. If a user request carries an outdated URL, POPs rewrite the URL and redirect the request to the new URL. This reduces the number of origin requests and enhances user access performance.

Create custom cache keys

You can configure custom cache keys by creating rules that generate cache keys based on different parts of an HTTP request, such as the URI, request parameters, HTTP request headers, or custom variables. This feature converts requests for the same file into a single cache key, which prevents the same request from being cached as different files. As a result, this improves the cache hit rate, reduces origin fetches, and decreases response times and bandwidth consumption.

Configure CORS

After you add your website to Alibaba Cloud Dynamic Content Delivery Network (DCDN), you can configure custom HTTP response headers to enable cross-origin access.

Note

For dynamic requests, you can ignore the request hit ratio or byte hit ratio due to the following reasons:

  • Data between the client and DCDN POPs is transmitted over HTTP/2, which supports header compression. Back-to-origin requests are sent over HTTP. The traffic of back-to-origin requests must be more than that of edge access requests.

  • By default, DCDN POPs add headers that mark DCDN information to back-to-origin requests. The headers also increase the size of back-to-origin requests.

In both cases, a small amount of byte hit data exists and can be ignored.