A low Content Delivery Network (CDN) cache hit ratio increases the workloads on origin servers and causes low access efficiency of static resources. You can select an optimization strategy to improve the cache hit ratio based on the specific cause.
Alibaba Cloud CDN accelerates the delivery of static resources by caching the static resources to CDN nodes that are nearest to the clients. When a client requests a resource, the CDN node retrieves the requested resource cached on the nearest CDN node instead of the origin server. Therefore, CDN cache hit ratios affect user experience. The increase of cache hit ratios has become a core element of the CDN performance.
- Byte cache hit ratio = Number of bytes returned for cache hits/Number of bytes returned
for all requests
Note A lower byte cache hit ratio indicates a higher amount of back-to-origin traffic. A higher amount of outbound traffic from the origin server indicates a larger bandwidth value and heavier workloads of the origin server. Therefore, back-to-origin traffic represents the amount of workloads on the origin server, and the byte cache hit ratio is the major concern in actual business scenarios.
- Request cache hit ratio = Number of cache hits/Number of all requests
View CDN cache hit ratios
The Alibaba Cloud CDN console displays byte hit ratios on the Quality Monitoring tab, as shown in the following figure.
- Log data
Alibaba Cloud CDN records the cache hit status of all requests. For more information about the log format, see Download log data. The cache hit status field is displayed as HIT or MISS. Sample log entry:
26/Jun/2019:10:38:19 +0800] 192.168.53.146 - 1542 "-" "GET http://www.aliyun.com/index.html" 200 191 2830 MISS "Mozilla/5.0 (compatible; AhrefsBot/5.0; +http://ahrefs.com/robot/)" "text/html"Note The hit status only indicates the hit status of CDN L1 nodes. For example, if the requested resource is not found in the cache of CDN L1 nodes but is found in the cache of CDN L2 nodes, the hit status is still displayed as MISS.
Increase CDN cache hit ratios
The following table describes the causes of a low cache hit ratio and the corresponding optimization strategies.
|Create a cache expiration rule||When the ETag or Last-Modified response header is not returned, the requested static resource fails to be cached on CDN nodes.|
|Retain URL parameters||When the URL of a request includes a query string or other variable parameters, the requested resource needs to be retrieved from the origin server.|