All Products
Search
Document Center

CDN:FAQ about refresh and prefetch

Last Updated:Apr 12, 2024

This topic provides answers to some commonly asked questions when you use the refresh and prefetch features of Alibaba Cloud CDN.

What are the differences between refresh and prefetch?

  • Refresh: 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 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.

Are refresh and prefetch performed in sequence?

Refresh and prefetch are different operations and do not necessarily follow a strict sequence. However, in actual practice, the two operations may involve a natural logical order based on the application scenario. If resources on your origin server are updated and you want to update the cache on Alibaba Cloud CDN points of presence (POPs):

  1. Refresh first: Outdated files in the cache are deleted. This way, visitors can obtain up-to-date resources on the origin server in subsequent access.

  2. Prefetch later: After files in the cache are refreshed, the up-to-date content is prefetched and cached to POPs. This ensures that visitors can obtain requested resources at the earliest opportunity.

  3. The first time you use Alibaba Cloud CDN, no cache exists. In this case, you can prefetch resources to POPs.

Should I enter the URL of the origin server or the URL that corresponds to the accelerated domain name for refresh and prefetch?

Refresh and prefetch are performed on the content hosted on the accelerated domain name. Therefore, you must enter the URL that corresponds to the accelerated domain name. This is because Alibaba Cloud CDN identifies and manages the cache by using the accelerated domain name, and refreshes or prefetches requests from the specified URL of the accelerated domain name. This ensures that the cache on POPs is preloaded or updated at the earliest opportunity.

How do I refresh the cache for a wildcard domain?

Alibaba Cloud CDN cannot directly refresh all cached content for a wildcard domain. Therefore, you cannot enter https://*.example.com/file01.html or https://*.example.com/file02/. Instead, you must submit a refresh request for the directory of a specific subdomain or a specific URL. Enter only one URL on each line.

How long does it take for refresh and prefetch tasks to take effect?

  • A refresh task takes effect 5 to 6 minutes after being submitted. 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.

  • 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.

Can I include a custom request header for prefetch?

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 PushObjectCache operation and specify a custom prefetch header by configuring the WithHeader parameter.

How do I increase the daily quota for refresh and prefetch?

  • URL and directory refresh

    By default, each Alibaba Cloud account can refresh 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.

  • Resource refresh based on regular expressions

    By default, each Alibaba Cloud account can submit a maximum of 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.

  • Prefetch

    By default, each Alibaba Cloud account can submit up to 1,000 URL prefetch tasks per day. If the daily peak bandwidth of your Alibaba Cloud account exceeds 200 Mbit/s, you can apply for a quota increase by following instructions in Quota management.

    The prefetch queue of each Alibaba Cloud account can contain up to 100,000 URLs. Alibaba Cloud CDN executes prefetch tasks based on the time at which you submit the URLs.

Is automatic refresh or prefetch supported?

For information about how to automate refresh and prefetch tasks, see Run scripts to refresh and prefetch content.

How do I check whether a prefetch task is complete?

  1. Log on to the Alibaba Cloud CDN console.

  2. In the left-side navigation pane, click Refresh & Prefetch.

  3. Set the Operation parameter to Prefetch, enter a URL in the URL field, and then click Submit. You can view the details and progress of a prefetch task on the Records tab. The prefetch task is complete when the progress reaches 100%. The prefetch task may require a long period of time to complete if you have a lot of objects to prefetch.

    Note

    If the status of a prefetch task is successful, the task is submitted.

  4. Run the following command to query the progress of a prefetch task:

    curl -I 'http://example.aliyundoc.com/test.json'

    The following figure shows a sample output. TB1oFf2JFXXXXa9XXXXXXXXXXXX.png

    Note
    • The first half of Via represents the status of the L2 POP. "H" represents a hit and indicates that the file is already prefetched to the L2 POP and does not need to be loaded from the origin server.

    • The second half of Via represents the status of the L1 POP. "M" indicates that no cache exists on the L1 POP and data must be loaded from the L2 POP.

References

You can call the DescribeRefreshTaskById operation to query the status of refresh and prefetch tasks. For more information, see DescribeRefreshTaskById.

How do I update files without the need to rename them after my domain name is accelerated by Alibaba Cloud CDN?

When you use Alibaba Cloud CDN to accelerate access to resources, you can use the following methods to update files:

  • When you update a file on the origin server, we recommend that you add a version number to the file name to differentiate file versions after updates.

    This way, each version of the file after an update has a unique name. For example, you can name a file img-v1.0.jpg before the file is updated and img-v2.1.jpg after the file is updated.

  • For files that must be updated with the same name, you can update the files by using the Alibaba Cloud CDN console or API. For detailed operations in the console, see Refresh and prefetch resources. For information about the API operations, see Refresh and prefetch. If the resources that you request are not updated after you refresh and prefetch the resources, see Why are the requested resources not updated after I use the refresh and prefetch features of Alibaba Cloud CDN?

Why does my prefetch task fail?

Prefetch tasks may fail due to the following reasons:

  1. Incorrect URL: Check whether the URL of the resource that you want to prefetch is correct. This includes verifying that there are no spelling mistakes, incorrect paths, or non-existent files. Then, confirm that the URL can be accessed by using a browser.

  2. Unavailable origin server: Check whether the origin server is overloaded or down. If the origin server cannot be accessed as expected, the prefetch task fails.

  3. Excessive tasks: If you submit a large number of prefetch tasks at the same time, some of the tasks may fail because the system is too busy. We recommend that you prefetch resources in batches to prevent excessive pressure on the bandwidth of the origin server.

  4. Resource cannot be cached:

    • Check whether the resources that you want to prefetch can be cached. Alibaba Cloud CDN complies with the configurations of origin headers. If the Cache-Control header of a resource is set to no-cache, no-store, or private, the resource cannot be cached.

    • Check the value of Expires or max-age. Make sure that the parameter value is not 0. A non-zero value indicates that the resource can be cached.

    For information about the cache rules of Alibaba Cloud CDN, see Default cache rule and priorities of cache rules.

  5. A directory prefetch request submitted

Why are the requested resources not updated after I use the refresh and prefetch features of Alibaba Cloud CDN?

Causes

The following section describes the possible causes:

  • The previous browser cache is accessed and returned.

  • The resources on the origin server are not updated.

  • The refresh and prefetch tasks are not complete.

Solutions

  • Clear the browser cache and refresh the web page.

  • Modify the local hosts file to map the domain name to the origin server. Then, check whether the resources on the origin server are updated. If the resources are not updated, update the resources on the origin server and then use Alibaba Cloud CDN.

  • Log on to the Alibaba Cloud CDN console and check whether the refresh and prefetch tasks are complete. If the tasks are not complete, we recommend that you re-run the tasks. For more information, see Refresh and prefetch resources.

Do I need to separately prefetch HTTP and HTTPS pages?

No, you need to only prefetch one of the pages. For example, if you have prefetched https://example.com/aaa.mp4, you do not need to prefetch http://example.com/aaa.mp4.

Can I prefetch M3U8 files?

M3U8, developed by Apple, is an HTTP Live Streaming (HLS)-based playlist file format used for video streaming. M3U8 is an extension of the M3U format, where "8" indicates that the text is UTF-8 encoded. This format is commonly used in online and continuous streaming services. M3U8 files are plain text files that store the URL paths of segments of video files (usually TS or MP4 files).

Only M3U8 files can be prefetched. Each TS segment referenced in the list is not automatically prefetched. You can use scripts to prefetch M3U8 files. For more information, see Use scripts to refresh and prefetch M3U8 files.