Updated on 2024-08-22 GMT+08:00

Cache Prefetch

CDN simulates user requests and caches resources to CDN PoPs, so that users can obtain the latest resources from the nearest CDN PoP.

Typical Scenarios

Initial access: When you connect a domain name to CDN for the first time, you can prefetch large files including videos to improve user experience.

Installation package release: Before releasing a software installation package or upgrade package, you can prefetch the content to the globally distributed CDN PoPs. After the software or upgrade is launched, the CDN PoPs directly respond to the download requests of a large number of users, which improves the download speed and greatly reduces the pressure on your origin server.

Promotional activity: Before releasing a promotional campaign, you can prefetch the static content involved on the activity page to CDN PoPs. After the activity starts, the CDN PoPs respond to user requests for accessing all static content, which ensures service availability and improves user experience.

Precautions

  • Cache prefetch can be performed only for unbanned domain names in Enabled or Configuring state. For more information about the domain status, see Viewing Basic Domain Information.
  • The time required to complete a prefetch task depends on the number and size of target files, and on network conditions.
  • If the cache prefetch status of a URL is Completed, the prefetch is complete.
  • Prefetching a large number of files may fully occupy the bandwidth resources of the origin server. Therefore, you are advised to prefetch files in batches.
  • Dynamic files, such as ASP, JSP, and PHP files, cannot be prefetched.
  • If you have set cache-control to s-maxage=0, max-age=0, private, no-cache, or no-store on the origin server and enabled Origin Cache Control on the CDN console, the origin server does not allow caching. As a result, cache prefetch fails.
  • If Origin Cache Control is not enabled and the cache TTL of the content to be prefetched is set to 0, CDN cannot cache the resource and the prefetch fails.
  • You can also create a cache prefetch task for a domain name by calling an API. For details, see API Overview.

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 Prefetch & Purge.
  3. Click the Prefetch tab and enter URLs to be prefetched or drag a TXT file to the text box.
    Figure 1 Cache prefetch
    Table 1 Parameter description

    Type

    Description

    URL prefetch

    • CDN prefetches a specific file.

    The format of a URL in the text box or in the TXT file must meet the following requirements:

    • http:// or https:// must be included.
    • Enter one URL per row.
    • End the homepage URL with a slash (/). Example: http://www.example.com/
    • Each account can prefetch a maximum of 1,000 URLs per day or per task.

      Examples:

      http://www.example.com/file01.html

      http://www.example.com/file02.html

      https://example.huawei.com/download/app/abc.apk

    URL Encode

    If enabled, Chinese characters in URLs are automatically transcoded and only content of transcoded URLs is prefetched.

  4. Click Submit.

    After a prefetch task is submitted, you can view the status of the task on the Task Progress tab.