All Products
Search
Document Center

:Troubleshoot low cache hit ratios

Last Updated:Mar 22, 2024

The cache hit ratios that are displayed in the Alibaba Cloud CDN console are low, and the origin server receives a large number of requests from points of presence (POPs). This causes slow content loading and increases loads on origin servers. This topic describes how to troubleshoot low cache hit ratios.

Overview

If all requests are directed to the origin server, the cache hit ratio is extremely low. Unstable network conditions may also result in a low cache hit ratio. You can prefetch URLs, configure resource cache rules, and filter out the variable parameters in URLs to improve the cache hit ratio. For more information, see Increase the cache hit ratios of Alibaba Cloud CDN. You can perform the following operations to troubleshoot low cache hit ratios.

View the cache hit ratios and traffic statistics in the Alibaba Cloud CDN console

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

  1. Check the cache hit ratios displayed in the Alibaba Cloud console. Only cache hit ratios of L1 POPs are displayed in the Alibaba Cloud CDN console. The cache data of L1 POPs is obtained from L2 POPs instead of origin servers. Therefore, the actual cache hit ratio is higher than the cache hit ratio that is displayed in the Alibaba Cloud CDN console.

    Note
    • The data flow in Alibaba Cloud CDN is: client > L1 POP > L2 POP > origin server.

    • You can choose Monitoring & Usage Analytics > Resource Monitoring in the left-side navigation pane of the Alibaba Cloud CDN console, and view the cache hit ratio data on the Hit Rate tab.

      image

  2. View the traffic statistics about the accelerated domain name that you submitted. When your accelerated domain name has low traffic, the statistical calculation of the cache hit ratio is greatly affected even if fewer URLs miss the cache. For example, an accelerated domain name provides 10 URLs that allow Internet access. One of the URLs has a no-cache policy configured on the origin server. This policy causes Alibaba Cloud CDN to not cache resources for this URL. Therefore, the cache hit ratio is reduced to 90% even if requests for other URLs hit the cache.

    Note

    You can view the traffic and bandwidth statistics about the accelerated domain name on the Overview page in the Alibaba Cloud CDN console.

    image

  3. Check whether the QPS of the service is normal. By default, resources are cached on POPs based on the configured time-to-live (TTL). However, the disk space of POPs is limited. In the case of frequent access, the cached files are replaced based on the access frequency, and the files that are less frequently accessed are replaced by the files that are frequently accessed. This results in more origin fetch requests. Domain names that have a QPS lower than 20 are prone to this issue. We recommend that you prefetch resources on your domain name to ensure that the resources on POPs can be hit.

Check cache configurations

Perform the following operations to check whether the cache hit ratio is low due to some improper parameter settings:

  1. Check whether the Range Origin Fetch parameter is set to Force. For more information, see Configure range origin fetch. If you set the Range Origin Fetch parameter to Force, range origin fetch is performed based on the specified range size for all back-to-origin requests. The range origin fetch feature is a double-edged sword. In scenarios in which the files on origin servers are larger than 50 MB in size or origin servers have low bandwidth, range origin fetch can reduce network congestion during large file downloads. In scenarios in which the average size of the files on origin servers is small, such as smaller than 10 MB, content delivery is not optimized if you set the Range Origin Fetch parameter to Force. On the contrary, the efficiency of origin fetch is reduced, and more requests are redirected to origin servers. This reduces the cache hit ratio.

  2. Check the URL to the Alibaba Cloud CDN-accelerated resource contains variable parameters. If you frequently use URLs that contain variables and user requests contain different parameter variables, Alibaba Cloud CDN stores hash values of the URLs, and each URL triggers origin fetch. This way, the URLs cannot hit resources cached on POPs and Alibaba Cloud CDN cannot accelerate the delivery of the resources. In this case, we recommend that you enable the Ignore Parameters feature to remove uri and parameters that follow the question mark (?) before you cache resources on POPs. For more information, see Ignore parameters.

    However, if the origin server or users need to use parameters that follow the question mark (?), we recommend that you use Dynamic Content Delivery Network (DCDN), which provides more flexible origin fetch by using intelligent routing. Alibaba Cloud CDN retrieves resources from origin servers based on fixed edge POPs and central POPs, and has lower performance than DCDN for URLs that contain parameters that follow the question mark (?). Intelligent routing dynamically detects network quality and plans origin fetch routes. DCDN may redirect requests from edge POPs to origin servers or from edge POPs to central POPs and then to origin servers.

    Note

    For example, in the URL http://example.aliyundoc.com/1.txt?timestamp=14378923, the value of the timestamp parameter is different for each access. The cache hit status of MISS is returned for the first access to a resource regardless of whether the request URL meets the cache rules of Alibaba Cloud CDN, because the resource is not cached on POPs. However, the value of the timestamp parameter changes. Therefore, the URL for each access is different, and the cache hit status of MISS is returned. This affects the cache hit ratio.

  3. Check whether multi-replica caching is enabled for origin servers. In multi-replica caching, origin servers can return different values of the Vary header to user requests that have different values of the Accept-Encoding header, and POPs caches data based on the values of the Vary header. Requests that contain different values of the Vary header increase the number of back-to-origin requests, resulting in a lower cache hit ratio.

  4. Check whether the cache settings are configured correctly. If the cache-related header is set to an improper value on origin servers or a required header is not configured, the cache hit status of MISS is returned for each access request when the cache rule of Alibaba Cloud CDN is no-cache. This affects the cache hit ratio.

    • If the Cache-Control header is set to no-cache, no-store, max-age=0, or private, or the Pragma header is set to no-cache, POPs do not cache resources.

    • If response headers from origin servers do not contain the ETag or Last-modified header, POPs do not cache resources.

    • By default, POPs cache resources based on the cache-related header that is configured on origin servers. If you set a cache-related header to an improper value, such as max-age=0, cache on POPs is overwritten.

  5. Check whether a no-cache rule is configured in the Alibaba Cloud CDN console, such as setting the TTL of a directory or files that have a specific filename extension to 0 seconds.

  6. Check whether origin servers contain a large amount of dynamic content. Alibaba Cloud CDN is mainly used to accelerate static resources, such as CSS, JavaScript, and HTML files, images, texts, and videos. Dynamic resources such as PHP and JSP files, resources that contain internal logic processing, and cookies are retrieved from origin servers.

  7. Check whether frequent refresh operations are performed. The Alibaba Cloud CDN console provides the cache refreshing feature. After you submit a refresh operation, all resources that are cached on POPs become invalid. Therefore, the cache hit status of MISS is returned for all requests for the same URL. This affects the cache hit ratio.

  8. Check whether files are frequently accessed. If cached URLs are not frequently accessed, the cached URLs may be removed from POPs even if the URLs meet cache rules. Files cached on POPs are removed based on their access frequency. Files that are least frequently accessed are removed first. Access frequency indicates how frequently a file is accessed on POPs. If the access frequency of a file is low, the domain name to which the file belongs receives fewer requests.

References