0

Drupal 8.

Title sums up pretty much my question.

I'm wondering what is the best way to rebuild all my site's cache daily.

A cron job with Truncate table cache ? Module who rebuild cache on each site ?

Does a plugin exist?

closed as off-topic by leymannx, Shawn Conn, mradcliffe, sanzante, googletorp Nov 6 '18 at 16:18

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "Questions on programming, PHP, SQL, etc. that do not relate directly to Drupal are off-topic here, but can be asked on Stack Overflow." – sanzante, googletorp
  • "Questions asking to recommend or find a book, tool, module, theme, distribution, tutorial, or other off-site resource are off-topic for Drupal Answers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – Shawn Conn, mradcliffe
If this question can be reworded to fit the rules in the help center, please edit the question.

  • are you interested on all caches? or just website page caches for anonymous users? – Stefanos Petrakis Nov 1 '18 at 21:01
  • Website caches for anonymous users. – Simon Nov 2 '18 at 20:18
  • Why you would do such thing? – sanzante Nov 5 '18 at 15:42
  • @sanzante For an unknown reason, sometimes some "blocks" disappear from Anonymous user's view and if a flush cache it comes back so I figure that cache should be flush at least once a week. What do you think ? – Simon Nov 6 '18 at 17:18
  • I think you should investigate block disappearing. Cache does a good job keeping your site fast and responsive. Those blocks disappearing indicate a problem that could be impacting others parts of your application but you didn't notice yet. – sanzante Nov 7 '18 at 9:57
2

The simplest way is a cron job that calls drush @alias cr set for 24 hours. You can do that at the server level.

  • OK good. How do I do that ? What kind of cron job? Only cron job I know is the one you set in cpanel with a php file. – Simon Nov 1 '18 at 20:11
  • @Simon Go to CPanel. Create a new job. Add /path/to/drush @alias cr --yes as the file to be executed. Set your frequency. You can get /path/to/drush running which drush. – rovr138 Nov 1 '18 at 21:40
  • OK. Since im on Windows server, I created a scheduled Task to run drush @sites cr --yes and it seems be working but its really slow. Task is currently running since more than 2 hours.. and when I use cmd it took around 30 min. Not sure if its possible to do it that way. – Simon Nov 2 '18 at 20:21
  • C:\Windows\System32\cmd.exe drush @sites cr --yes in my site folder – Simon Nov 2 '18 at 20:22
0

Since the question focuses on website page caching for anonymous users, the case for Drupal 8 is quite simple:

Drupal 8 provides an Internal Page Cache module that is recommended for small to medium-sized websites. This core module, which is enabled by default, caches pages for anonymous users.

You don't need to do anything, apart from defining the expire duration of your caches for browsers and (reverse) proxies.

Most importantly:

The page cache in Drupal 8 is instantly updated when something has changed.

Source: https://www.drupal.org/docs/8/administering-a-drupal-8-site/internal-page-cache

Hope that covers the OP, good luck!

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