IIS缓存文件永不替换 [英] IIS cached files never replaced

查看:101
本文介绍了IIS缓存文件永不替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许我没有正确填写Google搜索的字词来丢失某些内容,但是IIS 8.5和缓存出现了问题.我设置了一个服务器,按照所有标准,该服务器应仅提供静态文件.显然,在更改文件时,应该提供新文件.问题在于,即使在服务器重新启动,将文件设置为立即过期,禁用缓存,禁用压缩以及关闭任何其他缓存功能之后,仍会使用带有旧时间戳记的旧文件.

Perhaps I'm missing something by not wording my Google searches correctly, but I've run into an issue with IIS 8.5 and caching. I have a server set up that by all standards should be serving only static files. Obviously, when a file is changed, the new file should be served up. The issue is that even after a server restart, setting files to immediately expire, didsabling caching, disabling compression, and turning off any other caching feature, the old file with its old timestamp is still being served.

我有以下设置:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <security>
            <requestFiltering allowHighBitCharacters="false">
                <verbs allowUnlisted="false">
                    <add verb="GET" allowed="true" />
                </verbs>
            </requestFiltering>
        </security>
        <caching enabled="false" enableKernelCache="false" />
        <urlCompression doStaticCompression="false" />
    </system.webServer>
    <location path="" overrideMode="Deny">
        <system.webServer>
        </system.webServer>
    </location>
    <location path="" overrideMode="Allow">
        <system.webServer>
        </system.webServer>
    </location>
</configuration>

文件所在的文件夹具有只读权限.一个有趣的事实是,如果我转到mydomain.com,则会显示旧版本,但是转到newmydomain.com会加载新文件(即使它们都指向相同的IP地址).

The folder in which the files are located has read only permissions. The interesing fact is that if I go to mydomain.com, the old version shows up, but going to newmydomain.com loads the new file (even though they both point to the same IP address).

推荐答案

如果随响应发送的缓存控制标头指示内容对于给定的内容不会更改,则HTTP客户端可以使用文件的旧版本.一段的时间.内容是否在服务器上更改都没有关系.

An HTTP client can use the old version of a file if the cache control header(s) sent with the response indicated that the content would not change for a given period of time. It does not matter if the content changed on the server or not.

例如,如果文件带有标题发送:

For example, if the file is sent with the header:

Cache-Control: Max-age=86400

然后,客户端可以在24小时内使用文件而无需联系服务器.如果文件在服务器上发生更改,客户端将不会知道该文件已更改,因为它甚至不会向服务器发出请求.

then for 24 hours the client can use the file without contacting the server. If the file changes on the server, the client won't know that the file changed because it won't even make a request to the server.

您可以添加必须重新验证缓存控制属性,以强制客户端始终发出服务器请求.

You can add the must-revalidate cache control attribute to force the client to always make a server request.

这篇关于IIS缓存文件永不替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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