ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Warm entries automatically after clearing them

Open stuartcusackie opened this issue 2 years ago • 6 comments

It seems to me that the static cache should be automatically warmed again after it is cleared.

For example, if I make changes to my 'primary' nav then the entire static cache is cleared. Rules:

'rules' => [
  'navigation' => [
    'primary' => [
        'urls' => [
        '/*'
      ]
    ],

So now nothing is cached and the website is slow. I have to manually run static:warm but usually I am unaware when my clients make changes to the navs. The same applies to globals.

I think this should be done automatically after any entry's static cache is cleared. It might be complicated because we may want to queue the warming, so I guess this would have to be an optional feature.

Thanks.

stuartcusackie avatar Apr 07 '23 11:04 stuartcusackie

How we tend to handle this is using a NavSaved listener, then Artisan::call('statamic:static:warm)

ryanmitchell avatar Apr 18 '23 13:04 ryanmitchell

You can do this using the UrlInvalidated event: https://github.com/statamic/cms/pull/8902

ryanmitchell avatar Jan 11 '24 12:01 ryanmitchell

Cool, I think I have a similar solution implemented, but I think this should be a core feature, maybe.

stuartcusackie avatar Jan 11 '24 12:01 stuartcusackie

Going by the conversation around that issue and the one linked to it, I think this is the solution.

ryanmitchell avatar Jan 11 '24 12:01 ryanmitchell

Thank you, I will try that out!

stuartcusackie avatar Jan 11 '24 12:01 stuartcusackie