How To Configure Cloudflare Page Rule To Fix Cf-Cache-Status DYNAMIC Issue

When you use Cloudflare as your website CDN server, you always need to know whether the web page is cached by Cloudflare or not. And Cloudflare returns some HTTP response headers when you request the web page,  you can get the web page cached status from those response headers.

One of the response headers is Cf-Cache-Status, this header’s value shows whether the web page is cached by Cloudflare or not. The header value can be DYNAMIC or HIT. This article will tell you how to change the response header Cf-Cache-Status‘s value from DYNAMIC to HIT.

1. How To Inspect HTTP Response Header Cf-Cache-Status’s Value.

  1. You can use google chrome inspector to get the current web page response header’s value.
  2. Just open your web page in google chrome, right-click the web page area, then click Inspect menu item in the popup menu list.
  3. Click the Network tab in the inspector window, and reload the web page again.
  4. Click the resource name ( for example www.dev2qa.com or any web resource URL) on the inspector window Network tab left side, click Headers tab on the right panel, then you can see the resource request and response headers list.
  5. Expand the Response Headers section by clicking the arrow icon before the Response Headers section, then you can scroll to find the cf-cache-status response header and it’s value.
  6. You can read the article How To View HTTP Headers, Cookies In Google Chrome, Firefox, Internet Explorer for more detail.

2. What Dose Cf-Cache-Status Header’s Value Means.

  1. Below is the Cf-Cache-Status Header’s Value list.
  2. HIT: The web resource ( HTML page, image, js, etc) has been cached in the Cloudflare server and not expired. It is returned from the cache.
  3. MISS: The web resource has not been found in the Cloudflare cache, Cloudflare gets the resource from your original web server, puts it in the Cloudflare cache, and returns it to the web browser.
  4. EXPIRED: The cached web resource has expired, so Cloudflare will retrieve this web resource from your original web server again, put it in Cloudflare cache and return it to the web browser.
  5. BYPASS: The returned web resource is not cached and will not be cached, it is retrieved from the original web server directly.
  6. DYNAMIC: The web resource is returned from the original web server, it is not cached by Cloudflare by default. But you can configure Cloudflare to cache such web resources, then in the future request, the web resource will be cached.

3. Inspect Web Resource Response Header Cf-Cache-Status Value.

  1. By default, Cloudflare will not cache the HTML web page.
  2. So when you inspect the web page follow section 1’s steps, you will find a response header like cf-cache-status: DYNAMIC.
  3. But when you inspect other web resources ( for example js, image files, etc), the response header may be cf-cache-status: HIT or cf-cache-status: MISS, etc. This is because Cloudflare will cache such web resources by default.

4. How To Configure Cloudflare Page Rule To Change Web Page Response Header Cf-Cache-Status’s Value From DYNAMIC to HIT.

  1. What you need to do is just add a page rule in Cloudflare settings to make your web page being cached by Cloudflare.
  2. Log in to your Cloudflare management dashboard.
  3. Click the Rules icon on the page top area.
  4. Click Create Page Rule button.
  5. Input a url path ( for example www.abc.com/def* ) in the top input text box, you can use * in the url path.
  6. Select Cache Level in Pick a Setting drop-down list.
  7. Select Cache Everything in the Select Cache Level drop-down list.
  8. Click the Save and Deploy button to save and deploy the changes.
  9. You can select page rule trigger order in the Order selection list.
  10. If there are multiple page rules, the most top page rule in the page rule list will be triggered first.
  11. Now when you browse the Html page in the page rule url path, you will find the response Cf-Cache-Status header’s value will change to HIT or MISS.

Leave a Comment

Your email address will not be published. Required fields are marked *

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