Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When you update an image style, you need to clear your browser cache in order to see the updated image style take effect. There may be cases that you need to update the image ASAP and you can't rely on users clearing their browser cache.
Steps to reproduce:
- View Image in Safari
- Look at the image url: /sites/default/files/styles/river_thumbnails_teaser/public/field/image/my_image.jpg?itok=U5XXDilb
- In Chrome log in and update the image style
- Make sure to press the "Update Style" button
- Flush All Cache
- Refresh the page in Safari
- Look at the image url: /sites/default/files/styles/river_thumbnails_teaser/public/field/image/my_image.jpg?itok=U5XXDilb
The only way I can see the image take in effect right away is the clear my browser cache.
Do you think it would be a good idea to update the itok parameter value every time an image style is updated?
Comments
Comment #1
Elijah LynnJust ran into this issue because we are using Upload Replace module that will rename the new uploaded file to be the same name. The itok is generated with image_style_path_token() and will always generate the same token and the code in image_style_deliver() will always check the itok with the same algorithm for incoming image derivative generation requests.
So the logical option of having the itok param change is not that realistic and it would appear that the only option if we are using the same file name is to use Cache-control headers and pass a no-store along to the browser for those images.
Or maybe add a second query param onto the image to bust the cache...
Comment #2
Elijah LynnRelated http://drupal.stackexchange.com/questions/147146/image-cache-only-clears...
Comment #4
plachMarking this as a duplicate of #2884203: Invalidate client-side cache when image style is modified. as that one is more active.