How to clear cache via Cron Job

If you want to make sure that cache is cleared at a certain time every day, you can  create a cron job (through your webhosting control panel, check this video as a quick guide - and launch this function at whatever time you want: 


You can check detailed instructions in separate post here.

To do this, you have to create PHP file and name it what ever you want, for example rocket-clean-domain.php. Paste the following code inside:

<?php require( 'wp-load.php' );
	if ( function_exists( 'rocket_clean_domain' ) ) {

Place this file in WordPress installation's root (where wp-config.php and wp-load.php are located).

You can check this short video -

Note: If you place it on some other place, you need to edit path to wp-load.php in above's code   require( 'wp-load.php' ); to match its location.

Note: This function will only clear the cache, it doesn’t preload the cache. You have to use run_rocket_bot() or run_rocket_sitemap_preload() as well in order to trigger the preload.

Make sure to specify correct path to  rocket-clean-domain.php file in Cron Job settings.