You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use the AzureBlobStorageCache in my project for user profile pictures and would like to know how to invalidate the cache in case a user replaces their profile picture?
The linked question discusses deleting cached items.
When you upload a new image at the same source location the middleware will automatically detect a change and reprocess, cache, and serve the new image. However this requires a request for the image which means you need to invalidate the browser cache. The best way to do that is to create and register a no-op IImageWebProcessor that recognises a value you would send with your image, generally a time stamp containing the last edited date and time.
I’m fairly certain that the Umbraco CMS has an implementation of this you could copy
@JimBobSquarePants Thank you for your answer. In the Umbraco CMS repo there is only one IImageWebProcessor implementation which does not contain something related to caching.
In my project the GET endpoint always returns the old image after DELETE or POST, even if I disable caching in my browser. Everything works fine if I disable the Imagesharp.Web middleware.
I was able to isolate the problem, the cause was the browser cache or the default cache-control header. I have now solved the problem by setting the cache-control header to "public, must-revalidate, max-age=1" for the Blob when uploading to Azure Storage. With this it works correctly, but seems quite hacky to me....
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I use the
AzureBlobStorageCache
in my project for user profile pictures and would like to know how to invalidate the cache in case a user replaces their profile picture?Beta Was this translation helpful? Give feedback.
All reactions