首页 Troubleshoot a low CDN cache hit ratio

Troubleshoot a low CDN cache hit ratio

更新时间: 2026-04-25 02:30:15

A consistently low cache hit ratio in the Alibaba Cloud CDN console indicates that the origin server is receiving a high number of origin fetch requests from CDN. This can result in slower content loading and adds load to your origin server. You can follow the steps in this document to troubleshoot and optimize a low cache hit ratio.

Details

A low cache hit ratio means that most user requests are sent back to the origin server. Instability on the public network can then degrade acceleration performance, making it slower than direct access. To resolve a low cache hit ratio, you can prefetch URLs, configure cache rules, and filter variable parameters in URLs. For more information, see Improve the cache hit ratio of Alibaba Cloud CDN. First, follow the steps in this document to analyze potential causes.

Check cache hit ratio and traffic

The following section describes how to analyze the cache hit ratio and traffic in the Alibaba Cloud CDN console:

  1. The cache hit ratio displayed in the Alibaba Cloud CDN console reflects only the L1 POP (Point of Presence) hit ratio. Because L1 POPs retrieve cached data from L2 POPs and not directly from the origin server, the actual cache hit ratio is slightly higher than the value shown in the console.

    Note
    • Data in Alibaba Cloud CDN flows as follows: Client > L1 POP > L2 POP > origin server.

    • You can find cache hit ratio data on the Resource Monitoring tab under Resource Monitoring in the console.

      image

  2. Review the traffic for your accelerated domain name. If the domain has low traffic, even a small number of cache misses can significantly skew the cache hit ratio. For example, if an accelerated domain name provides 10 URLs and one has a no-cache policy set on the origin server, the cache hit ratio will not exceed 90%, even if all other requests are cache hits.

    Note

    You can find traffic and bandwidth data for your accelerated domain name on the Overview page in the Alibaba Cloud CDN console.

    image

  3. Check if your service QPS is normal. By default, CDN caches resources according to the configured cache time. However, POP disk space is limited. In high-traffic scenarios, more popular files replace less frequently accessed ones, triggering an origin fetch. This issue is common for domains with a QPS in the tens (e.g., 10-30 QPS). We recommend you prefetch resources for your domain to cache them on POPs.

Check cache configurations

Check if a low cache hit ratio is caused by misconfigured parameters:

  1. Check if forced range origin fetch is enabled. For more information, see Configure range origin fetch. When this feature is enabled, all origin fetch requests are sliced based on a set range size. This feature can be beneficial for origin servers with large files (over 50 MB) or narrow bandwidth, as it reduces network congestion. However, if your origin server primarily has small files (under 10 MB), forced range origin fetch provides no benefit and can reduce origin fetch efficiency, lowering the cache hit ratio.

  2. Check if the URLs for your accelerated content contain variable parameters. If your service frequently uses URIs with variables and each user request contains different parameters, CDN caches each unique URI as a separate object. This turns the CDN into a pass-through proxy, defeating the purpose of caching. In this case, we recommend enabling the ignore parameters feature. This feature removes parameters after the question mark (?) from the URI before caching. For more information, see Ignore parameters.

    However, if your origin server or users heavily rely on parameters that follow a "?", we recommend that you switch to the Edge Security Acceleration (ESA) product. ESA uses intelligent routing to provide more flexible origin fetches. In contrast, CDN uses a fixed, two-layer origin fetch path from an edge node to a central node and then to the origin server. For this reason, the performance of CDN for requests that heavily rely on variables that follow a "?" is slightly lower than that of Edge Security Acceleration (ESA). Intelligent routing dynamically plans the origin fetch path based on network quality detection. The path can be a direct origin fetch from an edge node to the origin server, or from an edge node to a central node and then to the origin server.

    Note

    For example, consider the URL http://example.aliyundoc.com/1.txt?timestamp=14378923, where the timestamp value changes with every request. A request for a URL that has not been prefetched is always a cache miss because the file is not yet on the POP, regardless of whether the URL matches any cache rules. Because the timestamp parameter changes for each request, each access is treated as a new URL. This results in repeated cache misses and lowers the cache hit ratio.

  3. Check if multi-replica caching is enabled on the origin server. This feature allows the origin server to respond with different Vary headers for requests with different Accept-Encoding headers. CDN then caches a separate version for each Vary header value. Requests with different Vary headers increase the number of origin fetch requests, which lowers the cache hit ratio.

  4. Check if cache settings are configured correctly. Improper cache headers or missing required headers on the origin server can prevent CDN from caching content, resulting in a cache miss for every request and affecting the cache hit ratio:

    • Improper cache header settings, such as Cache-Control set to no-cache, no-store, max-age=0, or private, or Pragma set to no-cache: CDN treats these directives with the highest priority and therefore does not cache the content.

    • Missing required headers: If the response from the origin server does not include ETag and Last-Modified headers, CDN will not cache the content.

    • Origin cache headers override CDN settings. By default, CDN prioritizes cache headers from the origin server. If the origin server sets an improper header, such as max-age=0, it overrides the CDN cache configuration.

  5. Check if a no-cache rule is configured in the CDN console, such as setting the cache time for a specific directory or files with a specific extension to 0 seconds.

  6. Check if the origin server has a large amount of dynamic content. CDN is primarily used to accelerate static resources such as CSS, JS, HTML, images, text, and video files. CDN forwards requests for dynamic resources like PHP and JSP files, or content that involves internal logic or cookies, to the origin server.

  7. Frequent cache refreshing operations. The CDN console provides a cache refreshing feature. Each refresh operation invalidates all cached content. Subsequent requests for the same URL will result in a cache miss, which lowers the cache hit ratio.

  8. Low content popularity. URLs that are not accessed frequently may be evicted from the cache, even if they meet all cache rules. CDN POPs use a least-recently-used (LRU) eviction policy to manage cached files. A file's popularity is its access frequency on that POP. Low popularity is often related to the overall low traffic of the domain.

References

阿里云首页 CDN 相关技术圈