页面缓存方式
发表于 2014-04-10

I added the following code into Web.config. This allows each of the specified resources to be cached at the client for maximum 8 days.


 <system.webServer>

 ...

   <caching>

     <profiles>

       <add extension=".png" policy="CacheUntilChange" varyByHeaders="User-Agent" location="Client" />

       <add extension=".gif" policy="CacheUntilChange" varyByHeaders="User-Agent" location="Client" />

       <add extension=".jpg" policy="CacheUntilChange" varyByHeaders="User-Agent" location="Client" />

       <add extension=".js" policy="CacheUntilChange" varyByHeaders="User-Agent" location="Client" />

       <add extension=".css" policy="CacheUntilChange" varyByHeaders="User-Agent" location="Client" />

       <add extension=".axd" kernelCachePolicy="CacheUntilChange" varyByHeaders="User-Agent" location="Client" />

     </profiles>

   </caching>

   <httpProtocol allowKeepAlive="true">

     <customHeaders>

       <add name="Cache-Control" value="public, max-age=691200" />

     </customHeaders>

   </httpProtocol>

 </system.webServer>