ETags,IIS7,内核缓存策略(enableKernelCache) [英] ETags, IIS7, Kernel Cache Policy (enableKernelCache)

查看:432
本文介绍了ETags,IIS7,内核缓存策略(enableKernelCache)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两部分问题(部分密切相关):使用IIS7采用的默认OOTB ETag策略,为什么我们在浏览页面时看不到If-None-Match / 304交互?

Two-part question (parts are closely related): with the default OOTB ETag policy that IIS7 employs, why don't we see the If-None-Match/304 interaction as we navigate through pages?

例如,为空缓存请求返回的标头是:

The headers returned for an empty-cache request, for instance, are:

Content-Type    image/png
Last-Modified   Thu, 03 Dec 2009 15:51:56 GMT
Accept-Ranges   bytes
Etag    "a8a0628a3074ca1:0"
Server  Microsoft-IIS/7.0
X-Powered-By    ASP.NET
Date    Tue, 22 Dec 2009 19:47:36 GMT
Content-Length  1780

...然后对页面的后续访问不会为图像生成304往返?

...and yet subsequent accesses to the page don't generate a 304 round-trip for the image?

此外,IIS7的默认 applicationHost 文件具有以下(1):

Also, the default applicationHost file for IIS7 has the following (1):

   <caching enabled="true" enableKernelCache="true">
   </caching>

enableKernelCache ='true'是否扩展到所有静态文件,释放你需要明确注册扩展名以授予 CacheUntilChange 作为内核策略(2):

Does enableKernelCache='true' extend to all static files, freeing you of the need to register extensions explicitly to grant CacheUntilChange as the kernel policy (2):

<caching>
  <profiles>
    <add extension=".gif" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
    <add extension=".png" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
    <add extension=".js" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
    <add extension=".css" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
    <add extension=".jpg" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
    <add extension=".jpeg" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
  </profiles>
</caching>

(1)%systemroot%\ System32 \inetsrv \ config \ applicationHost.config

(1) %systemroot%\System32\inetsrv\config\applicationHost.config

(2) http://labs.episerver.com/en/Blogs/Per/Archive/2009/3/Configuring-cache-expiration-on-IIS-7/

推荐答案

ETag的处理和相关的If-None-Match / If-Modified-Since在某种程度上取决于浏览器。您可以尝试使用几种不同的浏览器,看看会发生什么 - 一般情况下,如果您没有设置明确的到期时间,我会期望看到304,就像您说的那样。

The handling of ETags and the associated If-None-Match / If-Modified-Since is somewhat browser dependent. You might try a few different browsers and see what happens -- in general, if you don't set an explicit expiration time, I would expect to see the 304's, as you said.

对于内核缓存,默认情况下会启用静态文件。为了帮助看看发生了什么,我发现运行以下命令很有帮助:

For kernel caching, it is enabled for static files by default. To help see what's happening, I've found it helpful to run the following command:

netsh http show cachestate

这将显示有关当前缓存中的文件的信息。

That will show information about the files that are currently in the cache.

请记住,在内核缓存文件之前,通常必须在特定时间窗口内多次引用文件。

Keep in mind that files normally have to be referenced a couple of times within a certain time window before the kernel will cache them.

这篇关于ETags,IIS7,内核缓存策略(enableKernelCache)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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