Updated on 2023-12-28 GMT+08:00

ETag Verification

Background

An entity tag (ETag) of a URL is used to indicate whether the URL object is changed.

After a domain name is connected to CDN for acceleration, when a user request content for the first time, CDN PoPs pull content from the origin server, return content to the user, and cache the content to CDN PoPs. Within the configured cache TTL, when a user requests the content again, CDN does not need to pull content from the origin server. It returns the cached content to the user. When the content cached on CDN PoPs expires and a user requests the content:

  • If ETag verification is enabled, CDN verifies the ETag value. If the values of ETag, Last-Modified, and Content-Length do not change, CDN returns the cached content to the user, reducing the origin pull ratio and relieving the pressure on the origin server. If the value of ETag, Last-Modified, or Content-Length changes, CDN pulls content from the origin server.
  • If ETag verification is disabled, CDN does not verify the ETag value. If the values of Last-Modified and Content-Length do not change, CDN returns the cached content to the user. If the value of Last-Modified or Content-Length changes, CDN pulls the resource from the origin server.

Precautions

  • By default, ETag verification is enabled.
  • Domain names whose service type is whole site acceleration do not support this function.

Procedure

  1. Log in to Huawei Cloud console. Choose Service List > Content Delivery & Edge Computing > Content Delivery Network.

    The CDN console is displayed.

  2. In the navigation pane, choose Domains.
  3. In the domain list, click the target domain name or click Configure in the Operation column.
  4. Click the Origin Settings tab.
  5. Configure ETag Verification as required.
    Figure 1 ETag verification

Examples

Assume that you have enabled ETag verification for domain name www.example.com.

After the cache of a resource under the domain name expires, when a user requests the resource, CDN verifies the ETag. If the ETag value remains unchanged, CDN directly returns the cached resource to the user and recalculates the cache expiration time. If the ETag value changes, CDN pulls the latest resource from the origin server, returns it to the user, and caches the resource.