## Overview

Note

Customers in all Cloudflare plans can cache HTML files using Cloudflare Page Rules. However, only customers in the Business and Enterprise plans are able to bypass HTML caching whenever a cookie is sent with a *Bypass Cache on Cookie* setting using Cloudflare Page Rules.

You can [cache HTML of inactive users](https://blog.cloudflare.com/caching-anonymous-page-views/) and static content including likes, images, scripts, and stylesheets when using Drupal with Cloudflare by using the *Cache Everything* **Page Rule** with **Bypass Cache on Cookie** enabled.

***

## Enable Browser Cache TTL

To avoid browser cache collisions, you must first enable Bypass Cache on Cookie in the Cloudflare dashboard. To do this,

1\. Log in to your Cloudflare account.

2\. Click on the **Caching** app.

3\. Scroll down to **Browser Cache TTL** and choose **Respect Existing Headers**.

Now, you can configure the *Bypass Cache on Cookie* setting using Cloudflare **Page Rules**. 

***

## Set Bypass Cache on Cookie

When the *Bypass Cache on Cookie* page rule matches the criteria we set, Cloudflare will cache static images and other files, without caching HTML. To configure *Bypass Cache on Cookie* using **Page Rules**, 

1\. Log in to your Cloudflare account.

2\. Go to **Rules > Page Rules**.

3\. Click the **Create Page Rule** button and enter your domain. In the example below, the domain is [www.orangeclouded.com](http://www.orangeclouded.com). 

4\. Configure the Page Rules settings as follows:

* use the *\** wildcard operator on the Drupal installation path to match the entire domain
* set the Cache Level to Cache Everything
* text, set *Bypass Cache on Cookie* rule for the Drupal variables. This rule will override the *Cache Everything* rule when a user is logged into Drupal
* set the *Edge Cache TTL* setting to determine how long a Cloudflare cache server should store cached files.

If you use additional cookies in your Drupal site, you must ensure these are in the Regex statement: *SESS.\*|phpsessid=.\**

![The Create a Page Rule dialog with the Cache Level set to Cache Everything, Bypass Cache on Cookie set to Drupal variables, and Edge Cache TTL set to a month.](https://developers.cloudflare.com/_astro/page_rules_caching_static_HTML_with_drupal.BsAKJaAo_COle9.webp)

Now, when Cloudflare is serving cached files, a response header `Cf-Cache-Status: HIT` will be sent back to the browser.

***

## Related Resources

* [Caching Cloudflare CDN](https://developers.cloudflare.com/cache/concepts/default-cache-behavior/)
