Whats the difference between these two caching components in the web config?
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="90.00:00:00" />
</staticContent>
and
<caching>
<profiles>
<add extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
<add extension=".jpeg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
<add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
<add extension=".css" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
<add extension=".js" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:00:30" />
</profiles>
</caching>
I'm having trouble really finding info on the second version. What constitutes a change when it says "CacheUntilChange" and why would it have a duration then?
Thanks
I am facing similar doubts. This is what I figured out from the vast content on the internet.
Please feel free to correct me if I'm wrong or add more information in case I've missed anything.
1) <staticContent><clientCache
> caches only on the client side.
Caching profiles can be used to cache files on the client side as well as the server side.
To configure on both set location="ServerAndClient"
.
The policy
tag configures the client side caching policy, kernelCachePolicy
tag configures the server caching policy.
2) StaticContent caching does not support caching based on file types or extensions.
Caching profiles support caching based on extensions.
3) To apply staticContent caching on files at a particular location you can either use the location tag in the main web.config so that staticContent caching applies to all the files in that location.
e.g.
<location path="Content/common/images">
<system.webServer>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMaxAge="86400" cacheControlMode="UseMaxAge"/>
</staticContent>
</system.webServer>
</location>
The above tag will apply caching to all the files in the "Content/common/images" folder. Or staticContent tag can also be specified in a local web.config in the folder whose contents need to be cached.
For caching profiles, to be applied to a particular folder you can specify the caching profiles section in the config file local to the folder.
All the profiles applied in the main web.config will be applied in addition to the location specific profiles.
4) To configure StaticContent caching through IIS, you need to use the HTTP Response Headers configuration window
To configure caching profiles through IIS, you need to use the OutputCaching configuration window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With