All Products
Search
Document Center

Dynamic Content Delivery Network:Refresh and prefetch resources

Last Updated:Nov 27, 2023

Dynamic Content Delivery Network (DCDN) allows you to refresh and prefetch resources. This topic describes how to refresh and prefetch resources.

Features

  • Refresh: marks resources that are cached on all points of presence (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 refresh 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 common scenarios in which the refresh or prefetch feature is used.

Feature

Scenario

Refresh

  • Update and publish resources

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

  • Delete resources that violate the limits of DCDN

    After you delete resources that violate the terms that are described in Before you start from your origin server, visitors can still access the resources because the resources are cached on points of presence (POPs). In this case, you need to use the refresh feature to update the DCDN cache. This way, the resources are deleted from the 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

  • After you submit and complete a refresh 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 refresh tasks, more requests are redirected to the origin server for resources. This results in high bandwidth costs and more loads on the origin server.

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

  • After you submit and complete 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 increases the number of requests that are redirected to the origin server. The origin fetch process consumes more bandwidth resources and the origin server may be overwhelmed.

  • The period of time required to complete a prefetch task is proportional to the size of the files that you want to prefetch. In most cases, most prefetch tasks require 5 to 30 minutes to complete. A task that has a smaller average file size requires less time to complete.

  • If you want to use Resource Access Management (RAM) users to refresh or prefetch resources, you must have the required permissions. For more information, see Authorize a RAM user to prefetch and refresh resources.

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

  • 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 the HTTP 307 status code, 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.

Refresh resources

  1. Log on to the DCDN console.
  2. In the left-side navigation pane, choose Tools > Refresh and Prefetch.

  3. On the Refresh Cache tab, configure the refresh rules. The following table describes the parameters.

    2

    Parameter

    Description

    Operation

    Select Refresh.

    Operation Method

    Select URL, Directory, or Regular Expression.

    URL

    • By default, each Alibaba Cloud account can refresh content from up to 10,000 URLs and 100 directories including subdirectories per day. If the daily peak bandwidth of your Alibaba Cloud account exceeds 200 Mbit/s, submit a ticket to request a quota increase. For more information, see Quota management. Alibaba Cloud determines whether to approve your application based on your workloads.

    • By default, each Alibaba Cloud account can submit up to 20 refresh 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.

    • Refresh resources based on URLs

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

      • Enter only one URL on each line.

    • Refresh resources based on directories

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

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

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

      • Enter only one URL on each line.

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

      • If you refresh resources based on directories, the directories that you submitted are forcibly deleted. If a client requests resources from a deleted directory, the POP redirects the request to the origin server to retrieve up-to-date resources.

    • Resource refresh based on regular expressions

      For more information, see Configure URL refresh rules that contain regular expressions.

  4. Click Submit.

  5. View the refresh progress.

    After you submit a refresh 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 refresh. The refresh task may require some time to complete.

    Note

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

Prefetch resources

  1. Log on to the DCDN console.
  2. In the left-side navigation pane, choose Tools > Refresh and Prefetch.

  3. On the Refresh Cache tab, configure the prefetch rules. The following table describes the parameters.

    8

    Parameter

    Description

    Operation

    Select Push.

    Operation Method

    Only URL is supported.

    URL

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

    • Enter only one URL on each 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.

    • The prefetch queue of each Alibaba Cloud account can contain up to 100,000 URLs. DCDN executes prefetch tasks based on the point of time at which you submit the URLs. When the number of URLs in the prefetch queue reaches 100,000, DCDN rejects subsequent prefetch tasks.

    • 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 refresh and prefetch resources.

APIDescription
RefreshDcdnObjectCachesRefreshes specified objects on DCDN points of presence (POPs). The objects can be included in the content of files or URLs. You can refresh multiple URLs in each request.
Note URL refresh, directory refresh, and refresh based on regular expressions support cache sharing. If cache sharing is configured for a domain name, you can submit a refresh task with the root domain name or any associated domain name to refresh the cache.
PreloadDcdnObjectCachesPrefetches content from origin servers to POPs. This reduces workloads on origin servers because users can hit cache upon their first visits.
DescribeDcdnRefreshQuotaQueries the maximum number and the remaining number of URLs and directories that can be refreshed or the maximum number and the remaining number of URLs that can be prefetched per day.
DescribeDcdnRefreshTasksQueries details about refresh or prefetch tasks.
DescribeDcdnUserQuotaQueries resource quotas and resource usage.
DescribeDcdnRefreshTaskByIdQueries the status of refresh or prefetch tasks by task ID.