告诉浏览器删除图像缓存 [英] Tell the browser to drop cache of image

查看:148
本文介绍了告诉浏览器删除图像缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个常见的问题,当用户更改其个人资料图片时,它不会立即显示在网页上,他们将继续看到旧版本,直到浏览器决定放弃缓存版本。

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.

此问题的常见解决方案是添加一些唯一的查询字符串,以便浏览器不会缓存它,例如 img.png?cache-breaker = rjqwrj0

The common solution for this problem is to add some unique query string so that the browser will not have it cached, like img.png?cache-breaker=rjqwrj0.

这给我带来了另一个问题 - 它被记录在Web服务器的访问日志中,当它们被解析时,每个请求都被计为一个单独的资源,实际上它使用不同的查询字符串请求相同的资源。

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"...

它将为img提供缓存选项,而不会丢弃浏览器缓存

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

这篇关于告诉浏览器删除图像缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆