Help Center/ Content Delivery Network/ Troubleshooting/ Why Is the Cache of a Resource Inconsistent on Different PoPs?
Updated on 2024-06-06 GMT+08:00

Why Is the Cache of a Resource Inconsistent on Different PoPs?

Symptom

When users in different regions access a resource of your domain name with CDN acceleration enabled, CDN PoPs return different resource versions to them.

Possible Causes

  • You have enabled URL parameter filtering on the CDN console and configured the origin server to return resources based on URL parameters.

    Resources cached on CDN PoPs may be different when the URL parameters carried in the first request to the PoPs are different. When requests for the same resource are sent to different PoPs, the returned data is different.

  • The cache is not refreshed after the resource on the origin server is updated.

    If the resource is updated on the origin server but the access URL of the resource does not change, when a user accesses the resource, the PoP returns the cache. The PoP will pull the updated resource from the origin server and cache it only when the original cache expires. In addition, the cache eviction time varies by the access popularity in different regions. If the cache on some PoPs has been evicted, when a user accesses the resource, the PoP will pull the resource of the latest version from the origin server. If the cache on some PoPs is still available, the cache is directly returned to the user. As a result, the old and new versions may coexist in the cache of PoPs.

Solutions

  1. Do not use URL parameter filtering of CDN and the function of returning different resource versions based on URL parameters of the origin server at the same time.

    Check whether the origin server is configured to return different resource versions based on URL parameters. If yes, perform the following operations:

    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 Domains.
    3. Click the target domain name, click the Cache Settings tab, and check whether URL parameters are ignored.
    1. To filter out URL parameters for this resource, set Query Parameters to Ignore all.
  2. If the resource is updated on the origin server, purge the cache on CDN.

    Perform the following steps:

    1. Log in to Huawei Cloud console. Choose Service List > Content Delivery & Edge Computing > Content Delivery Network.

      The CDN console is displayed.

    2. Choose Prefetch & Purge in the navigation pane, click the Purge tab, and enter the URL or directory of the resource.

      You can also use the cache purge or prefetch API provided by CDN to purge the CDN cache. For details, see API Reference.