Cloudflare Cache by Device Type: A Guide for Website Owners
Configure Cloudflare Cache Rules to keep device-specific cached variants separate, with the hostname match, eligibility setting, and cache-key option explained.
Facts that can change should include a source and check date. Benchmark claims should state the plan, region, method, and test period.
To cache different versions of a site by device type in Cloudflare, create a Cache Rule for the relevant hostname, set Cache eligibility to Eligible for cache, and turn on Cache by device type under Cache key. This tells Cloudflare to vary the cache key by device type for requests that match the rule. The setting is specific to Cloudflare Cache Rules and is not a universal hosting control.
What device-type caching does#
Cloudflare describes caching as storing copies of frequently accessed content, including images, videos, and webpages, in geographically distributed data centers. Cloudflare can serve a cached copy instead of requesting the content from the website’s origin server.
When Cache by device type is enabled, Cloudflare varies the cache key by device type. This allows separate cached entries for the device types covered by the rule. It does not, by itself, create mobile or desktop versions of a page; your website must already provide the content variations you intend to cache.
How to configure the Cache Rule#
- Create a Cloudflare Cache Rule.
- Match the relevant hostname. Cloudflare’s example uses either of these expressions:
``text Hostname contains "example.com" ``
or:
``text (http.host contains "example.com") ``
- Replace
example.comwith the hostname for the site or host covered by the rule. - Set Cache eligibility to Eligible for cache.
- In Cache key, turn on Cache by device type.
- Save the rule and review the hostname, cache eligibility, and cache-key settings before relying on it for live traffic.
The hostname condition determines which requests the rule covers. The eligibility setting determines that matched content may be cached, while the cache-key option adds device type to the way Cloudflare separates cached entries.
When to use it#
This configuration is relevant when a hostname serves content that differs by device type and those variants need separate cache entries. If the site serves the same cacheable response to every device type, adding device type to the cache key may create unnecessary variations.
Cloudflare’s documentation describes the rule configuration, but it does not guarantee a particular speed, cache-hit rate, freshness result, or change in origin-server load for an individual website. Check that the rule matches the intended hostname and that the content is eligible for caching before evaluating its behavior.
Sources
- Cloudflare: Cache by Device Type Checked 2026-11-16
- Cloudflare cache documentation Checked 2026-11-16