1

Currently we have to clear it manually everyday logging in to admin console and browsing to Home->Administration->Configuration->Development->Performance

Is there way we can automate this job in Drupal 8. We tried with "cron", but that didn't help.

3
  • 2
    "We tried with "cron", but that didn't help." - you're certain you had a cronjob for drush cr?
    – Kevin
    Commented Nov 14, 2018 at 20:47
  • 2
    What did you try with cron that didn't work?
    – rooby
    Commented Nov 14, 2018 at 20:53
  • 2
    crontab -e and then maybe 0 0 * * * cd /var/www/drupal && drush cr?
    – leymannx
    Commented Nov 14, 2018 at 20:57

1 Answer 1

6

Despite you saying it didn't work with cron, I would suggest using cron in some way. :)

The CacheFlush module claims to allow configuration of this via its UI (although I haven't used it so cannot personally vouch for it).

If you are implementing custom code, drupal_flush_all_caches() will handle the flushing for you.

The Rules module also allows acting on Cron runs. Using rules you could either write a custom action that uses drupal_flush_all_caches() or find a module that provides one (I haven't seen any for D8 but that doesn't necessarily mean one doesn't exist).

You could also potentially do it outside of Drupal, using a cron job on your server to call drush cr for your site.

Aside: I would suggest also considering why you need to do this and what alternatives there are. I can't really think of many (any?) cases where I would want to do this instead of just invalidating the cache of specific content entities/pages as they are changed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.