Overview
If your cdn cache hit rate is low, the origin server will face heavy pressure, and the access efficiency of static resources will also decrease.
A higher cache hit rate means fewer back-to-origin requests, lower origin traffic, and faster response speeds.
I. What Is Cache Hit Rate?
Cache hit rate = number of requests directly returned from CDN node cache / total number of requests. If the hit rate is below 80%, it means the CDN is not fully effective—too many requests are going back to the origin.
II. Set Different Cache Times (TTL) for Different File Types
Setting reasonable cache expiration times for different types of resources can effectively improve cache hit rate, reduce back-to-origin ratio, and ease origin server pressure.
| File Type | Recommended TTL |
|---|---|
| Images (jpg, png, webp, svg) | 30 days |
| CSS, JavaScript | 7–30 days |
| Font files (woff, woff2, ttf) | 30 days |
| HTML (static pages) | 1 hour or no cache |
| API responses (JSON, XML) | No cache or 1 minute |
III. Ignore Irrelevant Query Parameters
Dynamic parameters in URLs (such as ?utm_source=xxx, ?ref=xxx) cause the same resource to be cached multiple times, wasting space. Configure the CDN to ignore these irrelevant parameters and keep only the necessary cache keys.
For example: style.css?version=1 and style.css?version=2 will be cached separately. If the version number is only used to control cache refresh, it is recommended to use filenames instead (style.v1.css, style.v2.css).
IV. Enable Tiered Cache
Tiered cache leverages the scale of the CDN network to greatly improve cache hit rate and reduce requests to the origin server. If an edge node misses, it first fetches from a parent node instead of going directly back to the origin. This can significantly reduce origin server pressure.
Most CDN consoles support enabling tiered cache (such as Cloudflare's Tiered Cache).
V. Preload Popular Content (Cache Preheating)
Before major promotions or new content launches, push popular resources to CDN nodes in advance. Users can hit the cache on their first visit, avoiding a large number of back-to-origin requests during peak periods.
Most CDNs support preheating (sometimes called "cache preheating" or "preload"), which can push hot pages and static resources in advance.
VI. Monitor Cache Hit Rate
Most CDN consoles provide cache hit rate reports. You can also check response headers through browser developer tools:
- Cloudflare:
cf-cache-status: HIT - EdgeOne:
X-Cache: HIT - Alibaba Cloud/Tencent Cloud:
X-Cache-Hit - Upyun:
X-Cache: HIT
VII. What to Do When Hit Rate Is Low?
Choose the corresponding optimization strategy based on the cause of the low hit rate:
| Problem | Solution |
|---|---|
| URL has random parameters | Configure CDN to ignore specified parameters |
| Different URLs correspond to the same content | Unify URL format |
| Cache time is too short | Extend static file TTL |
| Origin server does not set cache headers | Add Cache-Control headers in Nginx |
By properly configuring cache rules, enabling smart compression and security acceleration, you can effectively improve cache hit rate and reduce CDN costs.
