i can see stackoverflow add's both Expires
and Cache-Control
for their images , css, js etc, so i am trying to do the same, i tried this article
web.config
<location path="Content">
<system.webServer>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge"
cacheControlMaxAge="365.00:00:00" />
<clientCache cacheControlMode="UseExpires" httpExpires="Mon, 01 May 2023 00:00:00 GMT" />
</staticContent>
</system.webServer>
</location>
when i try to acess a css file in content folder : http://localhost:11111/Content/bootstrap.min.css
i get the following error
Error:
HTTP Error 500.19 -
Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.
Module CustomErrorModule Notification SendResponse Handler StaticFile Error Code 0x8007000d
Config Error Configuration element 'clientCache' already defined
i know clientCache
already defined, but i am concerned and want to know how to set both Cache-Control and Expires in response headers ?
Any help would be great.
Update:
As @Vitaly Kulikov answered and discussed in comment and using this and this posts i came to conclusion that in IIS we can's set both Expires and Cache-Control
in web.config, so i have planned to use OutputCache to set Expires for images at least and it works with 0.9 milliseconds delay. Hope helps someone.
According to the specification there is no way you can have both of them at the same time. But you have no reason to do that, you'll be fine with any of them.
Specification
If you look into Chrome source code, caching in browser has several simple rules
First:
Second:
Third:
That's it, no more rules there.