[Django]-Django: Force cache-refresh after update

0๐Ÿ‘

โœ…

Iโ€™ve settled on using djangos

@last_modified(last_modified_func)

decorator. See here.
The function can accept the same parameters as the decorated method (eg. the entity id in my case). With that I can simply look up the last modified meta data in the database and django will deal with the If-modified-since or If-unmodified-since headers from the request and either return a Not Modified response or the new image.

๐Ÿ‘คbeginner_

0๐Ÿ‘

How are you serving the image? A good idea would be to add a hash on to the end of the filename for the image, and then when you update the image, change that hash. This way, when the image is updated the browser is forced to reload the image.

You could even just use a timestamp of when the file was last updated??

๐Ÿ‘คtim-mccurrach

Leave a comment