putyourlightson / craft-blitz

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

Blitz does not clear cache on asset file replacements (Craft/Blitz 3) #607

Closed hiasl closed 5 months ago

hiasl commented 5 months ago

Hi,

We are on Craft 3.8.17 with Blitz 3.13.0 and discovered that Blitz does not clear the cached version of an entry when assets used in that entry get file-replaced within “Assets”.

AFAIK there are 3 ways to replace a file / an asset:

Interesting side note: When you update a field value on an asset (e.g. Title, Copyright or Alt Text) and click on “Save”, Blitz does clear the cache.

I have a minimum DDEV installation with the exact setup which I can provide via e-mail.

The problem seems to be solved in Craft 4 or higher versions of Blitz (don’t know which part is actually responsible for the problem), but I would need a solution for Craft 3 as well.

Thanks!

bencroker commented 5 months ago

This feature was added in Blitz 4.5.0.

The cache refresh process is now triggered when an asset’s file is replaced or its filename is changed (https://github.com/putyourlightson/craft-blitz/issues/514).

https://github.com/putyourlightson/craft-blitz/blob/develop/CHANGELOG.md#450---2023-07-19

Backporting this to Blitz 3 was always blocked by features that Craft 3.x added, but I’ve gone ahead and added this in https://github.com/putyourlightson/craft-blitz/commit/80d6c6510be6298960d80656982ce152eed8abe5 for the next release, which will require Craft 3.7.5 or above.

You can test this by running composer require "putyourlightson/craft-blitz:v3.x-dev as 3.14.0".

hiasl commented 5 months ago

Thank you Ben!

hiasl commented 5 months ago

This issue (https://github.com/putyourlightson/craft-blitz/issues/609) is related, in case someone is using Blitz 3.13 and newer together with the Relax plugin (https://plugins.craftcms.com/relax) in v1.

The reason why I only noticed by now is because I was not using Blitz 3.12.10 as stated above, but I was using 3.13.0.

bencroker commented 5 months ago

It's actually an unrelated issue that has to be fixed by the Relax plugin, see https://github.com/putyourlightson/craft-blitz/issues/609.

bencroker commented 5 months ago

Version 3.14.0 was just released.