statamic / ideas

💡Discussions on ideas and feature requests for Statamic
https://statamic.dev
30 stars 1 forks source link

Trigger static caching rules when entry unpublished #1146

Closed stuartcusackie closed 2 months ago

stuartcusackie commented 2 months ago

Apologies if this has been requested already.

I have rules to invalidate all entries when my primary navigation changes, however, if an entry within my primary navigation is unpublished then the caching rules are not triggered. This is because the navigation has not been directly edited, yet technically it has been edited by other means.

So I wonder if the core can be updated to:

I know this can be achieved with custom invalidation rules but I think this should be how it works by default.

Thanks!

duncanmcclean commented 2 months ago

This should be the case already - it's working for me w/ full-measure static caching.

When I mark an entry as unpublished, the entry's "show page" is invalidated and so is the collection "index page" (which is part of my static caching invalidation rules).

If this isn't working for you, please open a bug report and we can take a further look. Thanks!

stuartcusackie commented 2 months ago

Maybe it's a case of being on an old version. It's 4.50.0

Or maybe I'm not explaining it correctly. It's not that I want the cache of my index page wiped, I want every page listed in my caching rules for the navigation wiped:

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

So say my 'about' page appears in my 'primary' navigation, then the static cache should be wiped for all pages (/*), not just an index or home page. The primary nav has changed from unpublishing an entry contained in it, therefore the rules above should be triggered - all urls should be wiped.

duncanmcclean commented 2 months ago

Ah, I see... that makes sense! Re-opened.

ryanmitchell commented 2 months ago

@stuartcusackie take a look at: https://statamic.com/addons/thoughtco/cache-tracker - it may do what you need.

stuartcusackie commented 2 months ago

@ryanmitchell Looks very useful, thank you. I'll try it out someday.

duncanmcclean commented 2 months ago

Actually, it looks like you submitted a feature request for the same thing last year.

Closing this issue in favour of #976.