vollyimnetz/crop-thumbnails

Images are subject to bad caching behaviour

Closed this issue · 2 comments

Hi, we use this plugin on a WordPress that is behind a few caching layers (CloudFlare CDN is the big offender here), and when a user re-crops an image, the image doesn't update on the site unless we manually go in and flush the cache.

I would like to suggest that you add a random number or string to the cropped image's filename, so that it basically busts itself.

For example, a current file name looks like:

/uploads/2017/07/BannerImage-768x642-1-1024x605.png

I would like to see it like this:

/uploads/2017/07/BannerImage-768x642-1-1024x605-1510786859.png

This would also eliminate the need for having the JavaScript cache-busting code

hi, as i developped the plugin i stumble about cache busting myself.
Back then i thougth it is more robust for other plugins to have a filename that do not change. Remember - other plugins may cache the hole page html-content. A cropped thumbnail-file will then be deleted and is therefore can not be loaded.

Maybe this filename-caching should be optional activatable.

Did you try to update your cache on a filter/action?

Ok, i came to a conclusion. My plugin will not implement cache busting on its own. You may implement some algorithm on you own though. Have a look on the readme - there are 2 potential actions/filters you can use to handle cache-busting.

  • crop_thumbnails_after_save_new_thumb
  • crop_thumbnails_before_update_metadata