php_nub_qq php_nub_qq - 3 months ago 21
HTTP Question

Tell the browser to drop cache of image

I have the common problem where when users change their profile picture it will not immediately appear on the web page, they will keep seeing the old one until the browser decides to drop the cached version.

The common solution for this problem is to add some unique query string so that the browser will not have it cached, like


This causes another problem for me - it gets logged in the web server's access logs and when they are being parsed each request gets counted as a separate resource, where actually it is requesting the same resource with a different query string.

Is there any particular solution on the client side where I can tell the browser to explicitly drop the cache of the image that the user is about to upload, so it will get downloaded again when the page refreshes?

<img src="img.png?lastmod=yourtimeinnumbers"...

it will give a cache option for img without dropping the browser cache