Cache Content by Device Type (Mobile, Tablet, Desktop)

If you are on the Enterprise plan, you can set up Page Rules to separate your cached content based on the visitor's device type: mobile, tablet and desktop. This means getting all the benefits of Cloudflare's cache, while still targeting visitors with the correct content.

Here's how you can do this:

  1. First, go to the Page Rules page of the dashboard.
  2. Next, create a Page Rule.
  3. In the Page Rule, select the "Cache by Device Type" setting.

Once you have enabled this feature, Cloudflare will send an HTTP header on every request to your origin to specify the device type of the visitor:

CF-Device-Type: mobile|tablet|desktop

Your origin can then respond with the content appropriate for that device type, and know that we will cache it only for that device type.


Cache by Device Type does not work with single file cache purge. If you use Cache by Device Type, you must use Purge by Tag.

This option is only available to Enterprise sites. To upgrade to Enterprise, get in touch.

How is the device type identified? 

Cloudflare evaluates the User-Agent header in the HTTP request to identify the device type. We identify each device type with a case insensitive match to the regex below:

Mobile: (?:phone|windows\s+phone|ipod|blackberry|(?:android|bb\d+|meego|silk|googlebot) .+? mobile|palm|windows\s+ce|opera\ mini|avantgo|mobilesafari|docomo)

Tablet: (?:ipad|playbook|(?:android|bb\d+|meego|silk)(?! .+? mobile))

Desktop: Everything else not matched above.

Not finding what you need?

95% of questions can be answered using the search tool. This is the quickest way to get a response.

Powered by Zendesk