Understand Cache by Device Type (Enterprise plans only)

Learn how to control cache for specific device types.


The Cloudflare Page Rules app allows Enterprise domains to cache content by device type.  This allows all the benefits of Cloudflare's cache while targeting visitors with content appropriate to their device. 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.

To enable caching by device type:

  1. Log in to your Cloudflare account.
  2. Select the appropriate domain.
  3. Select the Page Rules app.
  4. Click Create Page Rule.
  5. Enter the URL to cache by device type.
  6. Choose the Cache By Device Type setting.
  7. Select On.
  8. Click Save and Deploy.

Once enabled, Cloudflare sends a CF-Device-Type HTTP header to your origin with a value of either mobile, tablet, desktop for every request to specify the visitor’s device type. 

If your origin respond with the appropriate content for that device type, Cloudflare caches the resource only for that specific device type.

To purge resources using Cache By Device Type, you must purge by Cache-Tag.

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