Brief CDN and Cache Server Background
Here i’ll show you three ways to verify if your website or a resource is being served through cache or not.
- Via Developer Tools
- Via Command-line or Terminal
- Via Third Party Website
Option 1 (Browser developer tools e.g Chrome’s “Network” tab or Firebug)
In order to view details of a resource on developer tools, you need to go to the “Network” tab. Then click a resource in the left panel. This’ll open up details related to that particular item. Head over to headers tab. In this example, we’re looking at http://talkwithstranger.com/free-chat-rooms where content is served via Cloudflare. You need to keep an eye on the following status message.
Option 2 (Command line/ Terminal)
Just open your command line or terminal and paste the following command.
Option 3 (Third Party Website)
This one is very easy to use as you don’t really need any additional tool except your browser. You can verify if your site or a specific resource is being cached is to use webpagetest.org. If you put the url in and run a test, you can then go to the details page on webpagetest.org after the test has run. The response headers will show the following if the CDN is caching your site or a specific resource:
Various types of Caching responses
- HIT: resource in cache, served from CDN cache
- MISS: resource not in cache, served from origin server
- EXPIRED: resource was in cache but has since expired, served from origin server
- STALE: resource is in cache but is expired, served from CDN cache because another visitor’s request has caused the CDN to fetch the resource from the origin server. This is a very uncommon occurrence and will only impact visitors that want the page right when it expires.
- IGNORED: resource is cacheable but not in cache because it hasn’t met the threshold (number of requests, usually 3), served from origin server. Will become a HIT once it passes the threshold.
- REVALIDATED: REVALIDATED means we had a stale representation of the object in our cache, but we revalidated it by checking using an If-Modified-Since header.
- UPDATING: A status of UPDATING indicates that the cache is currently populating for that resource and the response was served stale from the existing cached item. This status is typically only seen when large and/or very popular resources are being added to the cache.