putyourlightson / craft-blitz

Intelligent static page caching for creating lightning-fast sites with Craft CMS.
https://putyourlightson.com/plugins/blitz
Other
149 stars 36 forks source link

Cache clear and warm not triggered after saving an entry #160

Closed blaknite closed 4 years ago

blaknite commented 4 years ago

Question

Is the cache meant to be cleared, warmed and deployed automatically when entries are saved?

Additional context

I've set up a project with remote deploys using the shell deploy plugin. This project is set to automatically clear the caches and deploy. Currently the shell deploy just copies the blitz cache folder to another directory for testing. The project is set up to use the local warmer.

I do not have the debug console enabled.

Clicking "Refresh Cache" on the cache utility screen triggers the warmer and deployer correctly.

When editing and saving an entry, the warmer and deploy are not triggered.

bencroker commented 4 years ago

Yes, a cached page will be cleared, warmed and deployed when an entry that it references is saved. Can you double check that the page has already been cached and that the entry ID you are updating exists in the blitz_elementcaches table?

bencroker commented 4 years ago

Any update on this @blaknite?

bencroker commented 4 years ago

Please ensure you are not using @web as explained here: https://docs.craftcms.com/v3/sites.html#creating-a-site

blaknite commented 4 years ago

Thanks @bencroker and sorry for the slow response.

I followed the steps outlined in the linked issue:

This sounds like it might be more my misunderstanding about what is meant to be happening rather than blitz not working.

What is the difference between the after-save callback and doing the full cache reset from the blitz utility? It seems the full refresh will warm and deploy the whole site while the after save will only rebuild pages that have been visited. I was expecting to trigger a full rebuild on save. Is this possible?

Thanks again for you help.

bencroker commented 4 years ago

Correct, updating an entry will result in only pages that reference that page being refreshed. That way only pages that have changed will be cleared and warmed.

You should probably warm the entire cache before your first deploy. After that Blitz will automatically refresh only what needs to be refreshed. Make sense?

If you really want to warm the entire site before each deploy then you could add a console command to be executed before any other commands, for example:

/path/to/craft blitz/cache/warm

FYI the Shell Deployer was recently updated: https://github.com/putyourlightson/craft-blitz-shell/blob/v1/CHANGELOG.md

blaknite commented 4 years ago

Thanks @bencroker makes perfect sense. Cheers for your help. Very much appreciated