One of the disadvantages of Drupal is that it has a very steep learning curve and is not as user-friendly as WordPress. For example, to clear the cache on a regular basis you can’t simply tell a caching script to do it for you, no you need to know how the cache works, create a PHP file to clear it and then schedule a cronjob to clear it. Not as user-friendly as it could be. 

Nonetheless, with some research efforts the code to clear the cache was quickly found at drupal.org


// define static var
define('DRUPAL_ROOT', getcwd());
// include bootstrap
include_once('./includes/bootstrap.inc');
// initialize stuff
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// clear cache
drupal_flush_all_caches();

Copy the code appropriate for your Drupal version and paste it into a blank PHP file – make sure there’s no empty space before the opening PHP tag!

After that upload the file to your root home directory. Make sure to give it a random name – whoever knows the exact name of the file can clear your cache randomly.

Alright, now the easiest way to clear the cache on a frequent basis is not to visit this page manually, instead we are going to create a quick line in our crontab

1. Let’s say the PHP code is accessible via domain.com/cacheclearance.php

2. Open a SSH terminal and connect to your server. Enter pico clearcache

3. Paste this code wget domain.com/cacheclearance.php

4. Modify domain.com to match your actual site URL and then hit CTRL + X to exit pico and save the file. Make sure to enter chmod a+x clearcache to add the correct permissions to execute the file

5. Now, enter crontab -e – If you want to open crontab via pico run export EDITOR="pico" before you do that

6. Alright, now enter this at the bottom */30 * * * * /path/to/clearcache >dev/null 2>&1

7. We’re done – the cron daemon will now execute the clearcache script every 30 minutes and fetches the PHP site with your code. Whenever that happens it actually executes the PHP page (aside from downloading it) and clears the cache

Drupal’s cache will now be cleared every 30 minutes which is handy if you don’t want to do it manually