In this article
What does “mobile” mean for WP Rocket?
Usually the term “mobile device” would be used for smartphones as well as tablets, and every screen size in between. WP Rocket, by default, applies the term “mobile” to phones only. It does not consider tablets as “mobile” in the context of page caching. Mobile phones get detected by HTTP user agent.
Only phones, not tablets are treated as “mobile” by WP Rocket by default.
If you’re down with code, look at wp-rocket/inc/front/process.php around line #138 for the complete set of user agents WP Rocket will detect.
Treat tablets as "mobile"
As of WP Rocket 3.2, you can modify this default behavior to treat tablets as mobile with this helper plugin:
The helper can be useful if your theme or plugin uses the
wp_is_mobile function, which treats tablets as mobile devices. Also, note that both the Enable caching for mobile devices option and Separate cache files for mobile devices sub-option must be enabled for the helper to work. More about those options below.
Should I enable caching for mobile devices?
Yes, as a rule of thumb, you should enable caching for mobile devices.
Don't enable mobile caching if your website is not responsive, i.e. does not adapt to and fit onto smaller screens automatically.
Note: If no mobile cache option is enabled, WP Rocket will not serve any cached documents to mobile devices. Visitors viewing your website on their phone will receive (slower) page views directly from the WordPress database.
What does “Separate cache files for mobile devices” mean?
When this option is enabled, WP Rocket will create a dedicated cache file for mobile devices for every document that gets cached. As a result, WP Rocket will serve an entirely different cache file to mobile phones than to tablets, or desktop computers.
If you use any of the following plugins, this option will be enabled by default (and you will see the checkbox in the settings "grayed out") :
- WP Touch (Free Version)
- WP Mobile Detect
- WordPress Mobile Pack
- WP Mobile Edition
- Device Theme Switcher
- Easy Social Share Buttons for WordPress
Note: Dedicated mobile caching files have been introduced in WP Rocket 2.7. If you run a previous version and use any of the plugins mentioned above, you should not enable mobile caching.
If you visit the cache directory in wp-content/cache/wp-rocket/[example.com] (with example.com representing your domain), you will see 2 types of file names for each document:
- index.html(.gz) —cache files for tablets and desktop
- index-mobile.html(.gz) —cache files for phones
Should I enable both mobile caching options?
Depending on how responsive your design is, you would either just enable the first option, or both options in case your site provides any features loaded only on mobile devices.
Here’s a good rule of thumb on how to use these 2 options:
Use the first option
(Enable caching for mobile devices)
alone if your design is fully responsive and scales up and down seamlessly.
🛠 WP Rocket will serve the same cache file for a page request that a tablet or desktop computer would receive.
Additionally enable the second option
Separate cache files for mobile devices
) in case you use one of the plugins mentioned above or in the option’s description, or in case your site loads any resources on mobile devices only.
🛠 WP Rocket will serve a separate cache file to phones, different to the one tablets and desktop computers would receive.
Not sure what to do? 😰
When in doubt, always enable both options. This can result in twice as many cache files on your server, but it will in any case fit your needs, no matter how responsive your site is exactly.
Can separate mobile cache files be preloaded?
No, at this time preloading cannot emulate mobile visits, therefore separate mobile cache files cannot be preloaded. Mobile cache files will be generated by the first mobile visit to an uncached page.