Specify a 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' );

After defining a custom cache folder, you also need to: 

  • Deactivate / reactivate WP Rocket to update the advanced-cache.php file and htaccess file accordingly. 
  • 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. 

Alternatively, you can install the helper plugin below to define your paths, update the htaccess, delete old files and regenerate critical path CSS.  Your NGINX config has to be updated manually.

Heads Up! You must edit the file to define your  CUSTOM_WP_ROCKET_CACHE_ROOT_PATH and CUSTOM_WP_ROCKET_CACHE_ROOT_URL correctly. Do not define your paths in wp-config when using this helper plugin.

📥   Download (.zip):  WP Rocket | Custom Cache Folders

Developers: You can find the code for this plugin on GitHub.

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