Specify a custom cache folder and config path
Specify custom cache colder
By default, WP Rocket creates folders for the cache and other optimized files in:
It's possible to specify a custom location by defining the following constants in wp-config.php:
WP_ROCKET_CACHE_ROOT_PATHto specify the absolute cache folder path
WP_ROCKET_CACHE_ROOT_URLto specify the cache folder URL
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
It's also possible to specify a custom location for WP Rocket's configuration file, which is, by default, saved in:
To do so, you should define the following constant in the wp-config.php:
define( 'WP_ROCKET_CONFIG_PATH', $_SERVER['DOCUMENT_ROOT'] . '/new-path/' );
⚠️ Important: If you change WP_ROCKET_CONFIG_PATH, the new folder cannot be a shared directory, only WP Rocket's files should be present in this directory.
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 Load CSS Asynchronously is enabled)
- If you use this NGINX configuration, you will have to edit the paths that are hard-coded there.