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, table 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:
- First, go to the Page Rules page of the dashboard.
- Next, create a Page Rule.
- 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:
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|docomo)]])
Tablet: (?:ipad|playbook|(?:android|bb\d+|meego|silk)(?! .+? mobile))
Desktop: Everything else not matched above.