This topic summarizes troubleshooting methods for CDN cache scenarios by symptom: caching not taking effect and cache misses, low cache hit ratio and high origin fetch ratio, response header and CORS exceptions, video and large file exceptions, and content not being updated and access exceptions.
General preliminary steps
This topic applies to Alibaba Cloud CDN, with the accelerated domain name already onboarded and the CNAME resolution taking effect. If you use Dynamic Route for CDN (DCDN), some configuration entry points and feature names may differ. Refer to the actual console display.
The following check items apply to most cache issues. We recommend that you complete them one by one before you start troubleshooting to avoid incorrect conclusions caused by environmental interference:
|
Check item |
Description |
|
Verify that the CNAME resolution is correct |
Run |
|
Verify that the configuration has taken effect worldwide |
The rule status in the console must be Success. Delivering the configuration to POPs worldwide usually takes 3 to 5 minutes. |
|
Rule out the local browser cache |
Test in private browsing mode or by using |
|
Clear the existing CDN cache |
A new configuration applies only to new requests after it takes effect. For resources cached under the previous policy, submit a URL refresh or a directory refresh by using Refresh and prefetch. |
This topic uses setting the cache expiration time to 0 seconds as a fallback measure in several places. An expiration time of 0 means that every request triggers origin fetch, which significantly increases the load on the origin server and reduces the acceleration effect. We recommend that you use it only for dynamic content that genuinely requires real-time responses, such as API endpoints. Do not configure it globally for static resources.
Determine whether the cache is hit
Before you troubleshoot cache issues, check the response headers to confirm the cache status of the resource:
-
Use a GET request to check the response headers: Run
curl -v -o /dev/null "http(s)://accelerated-domain/resource-path". Acurl -Irequest (HEAD request) may not trigger the actual cache logic for the resource body on the POP in some scenarios, which leads to a false conclusion of a cache miss. We recommend that you use a GET request for verification. -
Check X-Cache to determine the hit status:
HITindicates a cache hit.MISSor the absence of this field indicates a cache miss, which means the request triggered origin fetch. -
Check Age and X-Swift-CacheTime to determine the remaining cache duration:
Ageindicates the number of seconds that the resource has been cached on the POP, and it must be interpreted together with X-Cache. If X-Cache is MISS and Age is 0, the request triggered origin fetch. If X-Cache is HIT but Age is 0, the resource was cached less than 1 second ago.X-Swift-CacheTimeindicates the total allowed cache duration. The remaining duration equals X-Swift-CacheTime minus Age. -
Confirm that the request passes through CDN: If the
Serverresponse header shows an origin identifier, such asAliyunOSSornginx, and CDN response headers such as X-Cache and X-Swift-CacheTime are absent, the request bypassed the CDN POP and went directly to the origin server. Rundig accelerated-domainornslookup accelerated-domainto confirm the final resolution result. Retain only the CNAME record assigned by CDN, and delete A/AAAA records pointing to the origin server IP and CNAME records pointing to the origin server domain name.
Caching not taking effect and cache misses
Low cache hit ratio and high origin fetch ratio
Response header and CORS exceptions
Video and large file exceptions
Content and access exceptions
What to do if the issue remains unresolved
Before you submit a ticket, we recommend that you locate the issue yourself in the following ways:
-
Check the real-time logs: In the console, check the cache status, origin fetch status, and response code distribution of the specific request to determine which URLs or time periods the issue is concentrated on.
-
Use the console diagnostic tool: Enter the problematic URL for detection to quickly obtain the resolution, origin fetch, and response header information.
-
Perform comparison tests: Access the same resource through CDN and directly from the origin server respectively, compare the differences in the response headers and content, and determine whether the issue is on the CDN side or the origin server side.
If the issue remains unresolved after self-troubleshooting, we recommend that you collect the following information before you submit a ticket to speed up the identification:
-
The accelerated domain name and the specific request URL.
-
The complete
curl -voutput that reproduces the issue (including the request headers and response headers). -
The approximate time, region, and ISP when the issue occurred.
-
The origin server type (OSS, ECS, SLB, third-party origin server, etc.) and whether the origin server supports range requests.
-
The troubleshooting steps that you have tried and the result of each step.
-
If the issue involves the cache hit ratio, provide a screenshot of the hit ratio in the console and the corresponding time range.