[英]Browser Caching using IIS8.5, am I doing it right?
I have applied the rules below to my web.config ;我已将以下规则应用于我的 web.config ;
<staticContent>
<mimeMap fileExtension=".less" mimeType="text/less" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="10.00:00:00" />
</staticContent>
<httpProtocol>
<customHeaders>
<remove name="Vary"></remove>
<add name="Vary" value="Accept-Encoding" />
<add name="Cache-Control" value="public" />
</customHeaders>
</httpProtocol>
<caching>
<profiles>
<add extension=".gif" policy="CacheForTimePeriod" kernelCachePolicy="CacheUntilChange" duration="5.00:00:00" />
<add extension=".png" policy="CacheForTimePeriod" kernelCachePolicy="CacheUntilChange" duration="5.00:00:00" />
<add extension=".jpg" policy="CacheForTimePeriod" kernelCachePolicy="CacheUntilChange" duration="5.00:00:00" />
<add extension=".ico" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="30.00:00:00" />
<add extension=".woff2" policy="CacheForTimePeriod" kernelCachePolicy="CacheUntilChange" duration="5.00:00:00" />
<add extension=".woff" policy="CacheForTimePeriod" kernelCachePolicy="CacheUntilChange" duration="5.00:00:00" />
<add extension=".ttf" policy="CacheForTimePeriod" kernelCachePolicy="CacheUntilChange" duration="5.00:00:00" />
<add extension=".js" policy="CacheForTimePeriod" kernelCachePolicy="CacheUntilChange" duration="2.00:00:00" />
<add extension=".css" policy="CacheForTimePeriod" kernelCachePolicy="CacheUntilChange" duration="2.00:00:00" />
</profiles>
</caching>
The thing is, when I check the response, I am having this output Cache-Control no-cache,max-age=864000
.问题是,当我检查响应时,我有这个输出
Cache-Control no-cache,max-age=864000
。 Does no-cache means the browser is not caching it? no-cache 是否意味着浏览器没有缓存它?
Here is an example output这是一个示例输出
Accept-Ranges bytes
Cache-Control no-cache,max-age=864000,public
Content-Encoding gzip
Content-Length 249
Content-Type text/css
Date Mon, 16 Mar 2015 07:37:29 GMT
Etag "872ee528715ed01:0"
Last-Modified Sat, 14 Mar 2015 16:08:50 GMT
Server Microsoft-IIS/8.5
Vary Accept-Encoding
X-Powered-By ASP.NET
Yes, You did it right and your page is caching well.是的,你做对了,你的页面缓存得很好。
You can refer to the explanation of Cache-Control MDN .可以参考Cache-Control MDN的解释。 the Cache-Control header value
no-cache means caches must check with the origin server for validation before using the cached copy.
Cache-Control 标头值no-cache意味着缓存必须在使用缓存副本之前与源服务器进行验证。 Your cache going to be revalidated on every
864000 seconds.It might revalidate the content using the
If-Match
or If-None-Match
headers with an ETag
, or it might use the If-Modified-Since
or If-Unmodified-Since
headers with a date.您的缓存将每864000秒重新验证一次。它可能会使用
If-Match
或If-None-Match
标头与ETag
重新验证内容,或者它可能使用If-Modified-Since
或If-Unmodified-Since
标头与一个约会。 Here is the directives explanation from MDN,这是来自 MDN 的指令解释,
max-age =
<seconds>
The maximum amount of time a resource is considered fresh.max-age =
<seconds>
资源被视为新鲜的最长时间。 Unlike Expires, this directive is relative to the time of the request.与 Expires 不同,该指令与请求的时间有关。
no-cache Caches must check with the origin server for validation before using the cached copy.
no-cache缓存必须在使用缓存副本之前检查源服务器以进行验证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.