Mobile Cache: Desktop View Displayed for Mobile Devices

Note: Since WP Rocket 2.8.11, if you're using our NGINX configuration, you don't have to do anything.

If your website is hosted on an NGINX server and you enable the dedicated mobile cache option in WP Rocket ( Create a caching file for mobile visitors), you may see the following misbehavior:

  • When you access a page on desktop first, the desktop cache will afterwards be served to mobile devices as well—incorrectly, as WP Rocket should create a dedicated mobile cache file and serve it to small screens.
  • When you access a page on a mobile device first, the correct mobile version will be cached and served to mobile later, whereas on your desktop you will see the correct desktop version afterwards.

The cause of this misbehavior is that WP Rocket cannot remove specific rewrite rules automatically to enable mobile detection on NGINX as it would do on an Apache server.

In order to solve the issue, you will have to edit your NGINX configuration.
Provided you use the  recommended NGINX configuration for WP Rocket, you can simply set the value in Line 24 of your configuration file to 0 (even though it says “Do not alter theses values” before):

# Do not alter theses values
#
set $rocket_bypass 0;    # Should NGINX bypass WordPress and call cache file directly?

This is basically what WP Rocket does for Apache, just translated to NGINX.

Tip: You can use a simple Chrome extension to determine whether or not your site is hosted on NGINX.

HTTP Headers Chrome Extension displaying header info