All Products
Search
Document Center

Dynamic Content Delivery Network:Purge and prefetch resources

更新時間:Oct 21, 2024

You can use the purge feature to delete resources that are cached on points of presence (POPs) and retrieve the latest resources from the origin server. This feature is suitable for resource updates and releases on the origin server, illicit resource cleanup, and domain name configuration changes. You can use the prefetch feature to cache frequently requested resources to POPs during off-peak hours. This feature reduces loads on origin servers and improves user experience.

Overview

  • Purge: marks resources that are cached on all POPs as expired. When a POP receives a request, the POP redirects the request to the origin server to retrieve the requested resource. Then, the resource is returned to the client and cached on the POP. The purge feature reduces the cache hit ratio.

  • Prefetch: prefetches resources from the origin server and caches the resources on POPs. When a POP receives a request, the POP directly returns the requested resource to the client because the resource is already cached on the POP. The prefetch feature increases the cache hit ratio.

Scenarios

The following table describes the scenarios where the purge or prefetch feature is commonly used.

Feature

Scenario

Purge

  • Update and release resources

    After resources on your origin server are updated, you can submit the URLs or the directories of the updated resources. Then, Dynamic Content Delivery Network (DCDN) purges the resources that are cached on POPs. This ensures that visitors can retrieve up-to-date resources from POPs.

  • Remove illicit content

    After you remove content that violates requirements described in Limits from your origin server, clients can still access the content because it has been cached on POPs. In this case, you can use the purge cache feature to clear the content from POPs.

Prefetch

  • Provide support for major events

    If you want to hold a major event, you can prefetch the static resources of the event page to POPs. After the event starts, visitors can access the static resources that are already cached on POPs. This accelerates content delivery.

  • Release installation packages

    Before you release an installation or upgrade package of a product, you can prefetch the package to POPs. After the product is launched, visitors can download the package from POPs. This accelerates content delivery and reduces loads on the origin server when a large number of visitors want to access your resources.

Usage notes

  • Usage notes on purge:

    • After you submit and execute a purge task, your resources that are cached on POPs are removed. When a POP receives a request for your resources, the request is redirected to the origin server to retrieve the resources. Then, the resources are returned to the client and cached on POPs. If you frequently run purge tasks, more requests are redirected to the origin server for resources. This results in high bandwidth costs and more loads on the origin server. We recommend that you perform this operation during off-peak hours.

    • A purge task takes effect 5 to 6 minutes after being submitted. If the resource you want to purge has a TTL of less than 5 minutes, you wait for it to expire instead of manually running a purge task.

    • URL purge, directory purge, and purge based on regular expressions support cache sharing. If cache sharing is configured for a domain name, you can submit a purge task with the root domain name or any associated domain name to purge the cache.

  • Usage notes on prefetch:

    • After you submit and execute a prefetch task, POPs immediately start to retrieve resources from the origin server. A large number of prefetch tasks lead to a large number of concurrent download tasks. This results in high bandwidth costs and more loads on the origin server. We recommend that you perform this operation during off-peak hours.

    • By default, prefetch requests include the Accept-Encoding:gzip header. If you want a prefetch request to include other headers or implement multi-replica prefetch, you can call the PreloadDcdnObjectCaches operation and specify a custom prefetch header by configuring the WithHeader parameter.

    • If the origin server returns a redirection-related status code, such as 307, the prefetch task does not follow the redirected address and fails. If the origin server returns the HTTP 301 or 302 status code and you have enabled 301 or 302 redirection in the DCDN console, the prefetch task is not affected. For more information, see Configure 301/302 redirection.

  • Common usage notes:

    • Resource Access Management (RAM) users must acquire required permissions before they can purge or prefetch resources. For more information, see Authorize a RAM user to purge and prefetch resources.

    • Once a purge or prefetch task is submitted, the task cannot be stopped until it is completed.

Purge resources

  1. Log on to the DCDN console.

  2. In the left-side navigation pane, choose Tools > Purge and Prefetch.

  3. On the Purge Cache tab, configure the purge rule according to the following table.

    2

    Parameter

    Description

    Operation

    Select Purge.

    Operation Method

    Select URL, Directory, or Regular Expression.

    URL

    • By default, each Alibaba Cloud account can purge content from a maximum of 10,000 URLs and 100 directories including subdirectories per day. If the daily peak bandwidth of your Alibaba Cloud account exceeds 200 Mbit/s, you can request a quota increase by following instructions in Quota management. Alibaba Cloud determines whether to approve your application based on your workloads.

    • By default, each Alibaba Cloud account can submit a maximum of 20 purge rules that contain regular expressions per day. If the daily peak bandwidth of your Alibaba Cloud account exceeds 10 Gbit/s, submit a ticket to request a quota increase.

    • Purge resources based on URLs

      • Each URL must start with http:// or https://.

      • Enter only one URL on each line.

    • Purge resources based on directories

      • Each URL must start with http:// or https:// and end with a forward slash (/).

        • Purge all files in the root directory: http://example.com/.

        • Purge all files in the /path/test/ subdirectory: http://example.com/path/test/.

      • Enter only one URL on each line.

      • You can purge content from up to 100 directories at a time, and purge content from up to 100 directories for a domain name per minute.

      • If you purge resources based on directories, resources in the directory are purged based on the actual condition. Specifically, when a visitor requests a resource in a directory, a POP retrieves the last modified time of the resource from the origin server. If the time is the same as the last modified time of the cached resource, the cached resource is returned. If the time does not match, the up-to-date resource is retrieved from the origin server, returned to the user, and cached on the POP.

    • Purge by URL with regular expressions

      For more information, see Purge cache by URL with regular expressions.

  4. Click Submit.

  5. View the purge progress.

    You can view the progress and details of a purge task on the Records tab. The progress varies with the number of objects that you want to purge. The purge task may require some time to complete.

    Note

    If you have enabled the Auto CDN Cache Update feature in the Object Storage Service (OSS) console, you cannot view the automatic purge tasks in the DCDN console.

Prefetch resources

  1. Log on to the DCDN console.

  2. In the left-side navigation pane, choose Tools > Purge and Prefetch.

  3. On the Purge Cache tab, configure the prefetch rule according to the following table.

    8

    Parameter

    Description

    Operation

    Select Prefetch.

    Operation Method

    Only URL is available.

    URL

    • Each URL must start with http:// or https://, must be a full path to the resource, and cannot end with a forward slash (/).

    • Enter only one URL per line.

    • Each Alibaba Cloud account can submit up to 1,000 URLs per day and up to 100 URLs in a request.

      If the daily peak bandwidth of your Alibaba Cloud account exceeds 500 Mbit/s, you can request a quota increase. For more information, see Quota management. Alibaba Cloud determines whether to approve your application based on your workloads.

    • Prefetch queue rules: The prefetch queue of each Alibaba Cloud account can contain a maximum of 100,000 URLs. DCDN executes prefetch tasks based on the time at which you submit the URLs.

    • The period of time required to complete a prefetch task is proportional to the size of the files that you want to prefetch. A task that has a smaller average file size requires less time to complete.

  4. Click Submit.

  5. View the prefetch progress.

    After you submit a prefetch task, you can view the task progress and details on the Records tab. The progress varies based on the number of objects that you want to prefetch. The prefetch task may require some time to complete.

Related API operations

You can call the API operations that are described in the following table to purge and prefetch resources.

API

Description

RefreshDcdnObjectCaches

Purges content on POPs by URL or directory. You can purge multiple URLs in each request.

Note

URL purge, directory purge, and purge based on regular expressions support cache sharing. If cache sharing is configured for a domain name, you can submit a purge task with the root domain name or any associated domain name to purge the cache.

PreloadDcdnObjectCaches

Prefetches content from origin servers to POPs. This reduces workloads on origin servers because users can hit cache upon their first visits.

DescribeDcdnRefreshQuota

Queries the maximum number and the remaining number of URLs and directories that can be purged or the maximum number and the remaining number of URLs that can be prefetched per day.

DescribeDcdnRefreshTasks

Queries the details of purge and prefetch tasks.

DescribeDcdnUserQuota

Queries resource quotas and resource usage.

DescribeDcdnRefreshTaskById

Queries the status of purge or prefetch tasks by task ID.