[英]cache busting using url-rewrite doesn't seem to work in iis
To bust the image cache using version string, I used following: 为了使用版本字符串来破坏图像缓存,我使用了以下命令:
<system.webServer>
<rewrite>
<rules>
<rule name="PNG Versioning">
<match url="(.*).png" />
<action type="Rewrite" url="{R:0}" appendQueryString="true" />
<conditions>
<add input="{QUERY_STRING}" pattern="ver=20190327" negate="true"/>
</conditions>
</rule>
</rules>
</rewrite>
</system.webServer>
But changing the value of version string still ends up in 304
. 但是更改版本字符串的值仍然会在304
结束。
If I manually add version string to the image url, on each each update of version string I get a 200
response code as expected. 如果我手动将版本字符串添加到图像url,则每次更新版本字符串时,都会得到200
预期的响应代码。
So, why isn't url-rewrite working similar to other method? 那么,为什么url-rewrite无法像其他方法一样工作?
I got the answer. 我得到了答案。 Cache- busting is not possible this way because: 由于以下原因,无法进行缓存清除:
When browser requests a resource: 当浏览器请求资源时:
If resource is in cache, it again sends a GET request to fetch the file but with some additional headers 如果资源在高速缓存中,它将再次发送GET请求以获取文件,但带有一些其他标头
if-none-match: 7dee9bc1f8cf1:0 如果不匹配:7dee9bc1f8cf1:0
if-modified-since: Tue, 04 Nov 2014 07:34:16 GMT 如果修改时间:自周二,2014年11月4日格林尼治标准时间
These additional headers instruct the server to only return the file if above conditions fail. 这些附加头指示服务器仅在上述条件失败时才返回文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.