All Products
Search
Document Center

:Why are files that are downloaded by using Alibaba Cloud CDN are inconsistent with files on the origin server?

Last Updated:Jan 16, 2024

Problem description

Files that are downloaded by using Alibaba Cloud CDN are inconsistent with files on the origin server.

Cause

If you request a file over Alibaba Cloud CDN, the system returns the file that is cached on points of presence (POPs). If the file on the origin server is updated by using the same name before the cache expires, the file that is cached is returned, which is inconsistent with the file on the origin server.

Note

If a file is updated by using the same name, the file content is modified, but the file name is not.

Solution

We recommend that you perform the following operations to resolve the inconsistency:

  • Rename files or use version numbers when you update files on origin servers.

    • Alibaba Cloud CDN is not notified if the origin server updates a file by using the same name. We recommend that you do not update files on origin servers by using the same names.

    • You can add a version parameter to request URLs. This way, Alibaba Cloud CDN can retrieve the most recent files from origin servers.

      Note

      If you add a version parameter to request URLs, you cannot enable the parameter filtering feature in the Alibaba Cloud CDN console. Otherwise, the parameter does not take effect.

  • After you update a file by using the same name, manually refresh the URL of the file by using the Alibaba Cloud console or calling an API operation. This way, the file on the origin server is consistent with the file on POPs. Refresh methods include directory refresh and URL refresh. For more information, see How do I update files after my domain name is added to Alibaba Cloud CDN? URL refresh provides a higher refresh speed for refreshing a single file. Directory refresh refreshes all files in a specific directory. In this case, the refresh speed is reduced. In addition, the bandwidth load on the origin server may increase because all requests that are destined for the files in the directory are redirected to the origin server.

    • URL refresh: marks specific files on POPs as expired. This way, requests that are destined for the files are redirected to the origin server. URL refresh takes effect within about 5 to 10 minutes. An Alibaba Cloud ID can refresh up to 2,000 URLs per day.

      Note

      The URL must start with http://.

    • Directory refresh: marks all files in a specific directory as expired. This way, requests that are destined for the files are redirected to the origin server. This method is suitable for scenarios in which a large number of files are refreshed. Directory refresh takes effect within 30 minutes. You can submit up to 100 directory refresh tasks per day.

      Note

      A directory must start with http:// and end with a forward slash (/). You need to set the Operation Method parameter to Directory before you perform a directory refresh. If you set the Operation Method parameter to URL, only the name of the directory that the URL points to is refreshed. Files in the directory are not refreshed.

  • If the origin server is an Object Storage Service (OSS) bucket, enable the CDN cache update feature in the OSS console. This way, when a resource that has the same name is updated in the OSS bucket, you can call the CDN refresh operation to refresh the resource URL. To enable the CDN cache update feature, perform the following steps:

    1. Log on to the OSS console.

    2. In the left-side navigation pane, click Buckets. On the Buckets page, click the name of the bucket that is used as the origin server.

    3. In the left-side navigation tree, choose Bucket Settings > Domain Names.

    4. Turn on Auto CDN Cache Update for your domain name.

Application scope

  • Alibaba Cloud CDN