Check if necessary cache headers present when requesting a file integrated with CDN. Use the description of the headers below.
Use the cURL command in a terminal (MacOS) and cmd (WindowsOS)
1. In the terminal, specify: curl -I http://cdn.example.ru/js/intlTelInput/css/intlTelInput.css
Where http://cdn.example.ru/js/intlTelInput/css/intlTelInput.css is a link to a file integrated with CDN.
2. You will get an output. Pay attention to the Cache-Control, Cache, X-Cached-Since, X-ID headers:
HTTP/1.1 200 OK
Date: Fri, 09 Jun 2017 12:54:24 GMT
Expires: Wed, 06 Dec 2017 12:51:43 GMT
Last-Modified: Sun, 01 Jan 2017 12:00:00 GMT
Cache-Control: max-age=315360000, public — cache lifetime in seconds
Cache: HIT - the file was delivered from the CDN cache.
X-Cached-Since: 2017-06-09T12:51:43+00:00 — when the file was cached.
X-ID: m9-up-e245 — the CDN server from which the file was delivered.
3. If you have any suspicions on the content caching, check the settings on the source, read the Troubleshooting Low Cache hit ratio article, or contact firstname.lastname@example.org.
Use a browser developer console
1.Open a browser (e.g. Google Chrome).
2.Open your site.
3.Press F12 (to open a developer console)
4. Choose the Network tab.
5. Refresh the page (press F5). You will get the list of all files downloaded from your site.
6.Find the static file (eg: jpeg, png, img) integrated with the CDN and click on it. For a faster search, use the filter in the panel left corner.
7. On the Headers tab on the right, you will find the headers set on your origin.
8. Analyze them using the description of the important headings below.
Important HTTP Headers
1. Check from which server (your or CDN) the content was sent is possible by the value of the X-Cache HTTP header:
- X-Cache: HIT — the file has been delivered from CDN
- X-Cache: MISS — the file has been delivered from your origin server.
2. Check from which CDN server the content was sent is possible by the header value:
- X-ID: [m9-up-e245] - the file has been delivered from the m9-up-e245 CDN-server.
3. The time when the file was cached on the CDN server can be checked by the value of the X-Cached-Since header:
- X-Cached-Since: 2017-06-09T12:51:43+00:00 — the time when the file was cached in a CDN node.
Cache-Control Header Parameters Compatible with CDN:
Cache-Control: Max-Age - sets the lifetime of the file in the cache in seconds.
Cache-Control: Public - indicates that not only the user's end client (browser) can cache the file, but also proxy servers, CDN servers, etc.
Cache-Control Header Parameters Incompatible with CDN:
Cache-Control: Private - the opposite of public directive - indicates that the file cannot be cached by proxies.
Cache-Control: No-cache - the file is not cached on CDN and each time
will be pulled from the origin.