Cloudflare Cache Detector

This tool will help you figure out whether a resource, be it HTML, CSS or javascript, is being cached by Cloudflare. Enter the URL you want to check into the Cloudflare cache detector below and it will let you know whether there is a cache hit or miss.

Cloudflare returns the cache status of an online resource through a response header called CF-Cache-Status. This header does not cause any behavior changes in web browsers, it is simply there as a way for the webmaster to know whether the resources are being cached or not. This tool will perform a basic head request against the URL you provide. It will check the headers to see if it contains the CF-Cache-Status header and if it does, it will check to see if it equals a hit.

There are 5 possible response types that the CF-Cache-Status header can contain. You can read each of them below with a description of what they mean.

HIT: This is obviously a positive response. The record is cached and the request made through the CDN hit the cache and did not hit your web server.
MISS: The cache was checked but the requested resource was not found. The following request will likely be a HIT
BYPASS: Cloudflare has been instructed not to cache this resource, likely through a page rule.
EXPIRED: This resource was cached before but has been living in the cache longer than the specified time for the cache to live. The cache will be refreshed for the next request.
DYNAMIC: This will appear if you are requesting a resource that Cloudflare does not cache by default. This is essentially a miss.

Help, CF-Cache-Status Header Is Missing!

If you are confident that all of your traffic is routed through Cloudflare’s CDN, and you can see a CF-RAY header in the response, why is the cache status header missing too? It could be for a few reasons, but it is most likely due to either a configuration issue where you have accidentally instructed Cloudflare not to cache this particular resource. Or because the content type of the resource you are requesting is not something that is normally cached by default. Typically you would see a dynamic header for this though.

Try testing javascript, CSS or image files. If these are also missing the headers, then you need to check your page rules to see if these file types are being bypassed. If these files do have the cache header, then it is a case that the content type needs a page rule added to ensure that it gets cached. Setting up page rules is very simple.

How To Cache HTML With Cloudflare

What a lot of people tend not to know is that Cloudflare can cache HTML pages as well as a cache for Javascript, CSS and image files. This can be done very easily using a page rule. You can create one that is set to cache everything. In these cases files that return HTML, XML, JSON, have .php extensions etc will be cached in Cloudflare. This will help you get incredibly fast page response times and take all of the stress away from your web server.

If you are using a CMS like WordPress, you will need to be careful about this. If your wp-admin page is cached, non logged in users will be able to view the data. They may not be able to save or modify anything but they will see be able to gain access to sensitive administration pages. This is why you should make sure to use additional page rules to add cache bypassing exceptions. The image below will show some examples of how to achieve this.

cloudflare page rules

Setting up Cloudflare Page rules to cache HTML and other content for a website

How To Manually Check If Cloudflare Cached a Resource

If you want to be able to check for this manually, you can visit a URL in your web browser and check the headers manually. To do this. Right-click on a page and click on “Inspect Element”. Firefox and Chrome both have the same setting for this. It will open a window with some HTML and there will be some tabs along the top. Move over to the “Network” tab. Minimize this window and go back to the main window and either refresh the current page or navigate to the page you want to test.

Once the page has loaded, go back to the inspection window and if you click on the resource, you will be able to see the CF-Cache-Status header listed with all of the other HTTP headers. The response type will be visible here.

cloudflare CF-Cache-Status Header response

This image shows the Cloudflare caching header visible in the response for the requested resource

The tool at the top of this page takes the manual process away. Enter your URL and this tool will perform this manual check for you automatically. The Cloudflare cache detector will simply check whether the response is present and let you know if the response is good news or bad news.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.