当 src 是重定向 url 到实际图像文件时如何防止从缓存加载图像

How to prevent loading image from cache when the src is a redirect url to the actual image file

全部:

当我尝试解决从缓存加载图像时的问题时,我从这个post:How to force a web browser NOT to cache images

中得到了一些答案

它谈到像

一样向 src 添加时间戳
<img src="picture.jpg?1222259157.415" alt="">

但在我的例子中,它不是直接图像 url,它是来自 github 的头像 url,例如:

<img src="https://avatars.githubusercontent.com/u/614?v=3" alt="">

当我添加时间戳 79399.92599998368 时,它变成:

<img src="https://avatars.githubusercontent.com/u/614?v=379399.92599998368" alt="">

不知为什么改了url这个src还能正确识别并得到图像?谁能告诉我为什么会这样以及浏览器如何处理这个问题?

谢谢

URL 中的问号 (?) 分隔位置和 query string,列出 GET 参数。

在这种情况下,github 会简单地忽略这些参数并提供由位置部分标识的图像。换句话说,github 只查看第一部分,因此始终提供相同的内容,但用户的浏览器显然无法预测这一点,因此如果整个 URL 没有,则需要始终加载内容完全适合缓存的。