NGINX configuration for WP Rocket

WP Rocket will work out of the box on NGINX servers. While this configuration is not required, it provides the rules that would otherwise be present in the .htaccess file on Apache/LiteSpeed servers.

Maxime Jobin has provided us with a configuration for NGINX. From the README file:

It enables NGINX to directly serve previously cached files without calling WordPress or any PHP. It also adds headers to cached CSS, JS, and images via browser cache.

Check it out on GitHub:

Thanks, Maxime! 🎩

Note: this configuration can be modified.

Additional NGINX tips

  • Read this article in case you have activated WP Rocket’s Mobile Cache option on NGINX.
  • If you're using a custom cache folder, you will need to adjust references to the original cache folder path in the configuration.
  • For users of the Nginx Helper plugin, automatic compatibility exists to purge both the NGINX and WP Rocket cache when either is cleared.

    The Nginx Helper plugin is needed only if the NGINX caching is enabled. This is to synchronize cache layers.

    Please note, Nginx Helper won't work out of the box. You need to make some changes at the Nginx end. You can see more information in the official tutorial list.

Note: Using the NGINX configuration alone with WP Rocket is generally more performant than using WP Rocket with NGINX caching.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.