OutputCache 未在整个持续时间内进行缓存
我做了一个简单的测试用例。
默认.asp:
<%=now%>
web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="default.asp">
<system.webServer>
<caching>
<profiles>
<add extension=".asp" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="01:00:00" varyByQueryString="*" />
</profiles>
</caching>
</system.webServer>
</location>
如果我请求default.asp 2次,页面会被缓存,那么日期时间值在一段时间内表示相同,但不是整个小时。
要测试此情况,请打开 default.asp 请求页面,直到该页面被缓存,然后等待 5 分钟并刷新页面。
我使用的是Windows 7 + IIS7.5
I made a simple testcase.
default.asp:
<%=now%>
web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="default.asp">
<system.webServer>
<caching>
<profiles>
<add extension=".asp" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="01:00:00" varyByQueryString="*" />
</profiles>
</caching>
</system.webServer>
</location>
If i request default.asp 2 times the page's get cached en the datetime value says the same for a period of time but not for the whole hour.
To test this open default.asp request the page until it is cached then wait for 5 minutes and refresh the page.
I am using Windows 7 + IIS7.5
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您能否澄清一下 IIS 中应用程序的生命周期是多少? IIS 是否会因不使用而剔除应用程序?
测试这一点的一种方法是每 20 秒刷新一次页面。如果缓存页面保持原始时间的时间超过您提到的 5 分钟,则表明应用程序正在被剔除。当您再次请求该应用程序时,它会重新生成缓存版本。
Can you clarify what the lifetime of the application is in IIS. Could IIS be culling the application due to non use?
One way to test this out would be to keep refreshing the page every 20 seconds. If the cached page keeps the original time for longer than the 5 minutes you mentioned then this would point to the fact that the application is being culled. When you then request this app again it generates the cached version afresh.
我进行了失败的请求跟踪并发现了以下内容。
如果页面不经常被命中,则即使未达到持续时间,缓存也会失效:
http://img819.imageshack.us/img819/7963/45303467.png
I did a failed request tracing and found the following.
If the page doesn't get frequently hit the cache invalidates even thought the duration isn't reached:
http://img819.imageshack.us/img819/7963/45303467.png