I have applied the rules below to my 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
. Does no-cache means the browser is not caching it?
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 . the Cache-Control header value means caches must check with the origin server for validation before using the cached copy. 意味着缓存必须在使用缓存副本之前与源服务器进行验证。 Your cache going to be revalidated on every 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.秒重新验证一次。它可能会使用If-Match
或If-None-Match
标头与ETag
重新验证内容,或者它可能使用If-Modified-Since
或If-Unmodified-Since
标头与一个约会。 Here is the directives explanation from MDN,
=
<seconds>
The maximum amount of time a resource is considered fresh. =<seconds>
资源被视为新鲜的最长时间。 Unlike Expires, this directive is relative to the time of the request.Caches must check with the origin server for validation before using the cached copy. 缓存必须在使用缓存副本之前检查源服务器以进行验证。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.