Specify a Custom Cache Folder and Config Path

Specify Custom Cache Folder

By default, WP Rocket creates folders for the cache and other optimized files in:

/wp-content/cache/

It's possible (in WP Rocket 3.2+)  to specify a custom location by defining the following constants in wp-config.php:

  • WP_ROCKET_CACHE_ROOT_PATH to specify the absolute cache folder path
  • WP_ROCKET_CACHE_ROOT_URL to specify the cache folder URL

For example:

define( 'WP_ROCKET_CACHE_ROOT_PATH', $_SERVER['DOCUMENT_ROOT'] . 'new-path/cache/' );
define( 'WP_ROCKET_CACHE_ROOT_URL', 'https://example.com/new-path/cache/' );

Specify Custom Config Location

Since WP Rocket 3.5, it's also possible to specify a custom location for WP Rocket's configuration file, which is, by default, saved in:
/wp-content/wp-rocket-config/

To do so, you should define the following constant in the wp-config.php:

  • WP_ROCKET_CONFIG_PATH

For example:

define( 'WP_ROCKET_CONFIG_PATH', $_SERVER['DOCUMENT_ROOT'] . 'new-path/' );

After defining a custom cache folder and / or a custom configuration folder, you also need to: 

  • Deactivate / reactivate WP Rocket to update the advanced-cache.php file and htaccess file accordingly and recreate the configuration file in the new location. 
  • Delete old wp-content/cache folders manually via FTP (wp-rocket, min, busting, critical-css)
  • Regenerate your Critical Path CSS (if Optimize CSS Delivery is enabled)
  • If you use this NGINX configuration, you will have to edit the paths that are hard-coded there. 
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.