Reputation: 552
I've got an ASP.NET site running under VS10 Dev server. I'd like for certain static content files to be served with a long max-age cache directive, but can't seem to get it working.
I have this in my web.config:
<system.webServer>
<caching enabled="true" enableKernelCache="true">
</caching>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
And in folder of content to cache
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge"
cacheControlMaxAge="30.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
But it doesn't work either, it always serves with Cache-Control: private
So, is this staticContent configuration supported? If not, any workarounds? If so, what am I missing?
Headers i get in all requests:
Server: ASP.NET Development Server/10.0.0.0
Date: Thu, 23 Feb 2012 20:47:56 GMT
Cache-Control: private
Content-Type: application/octet-stream
Content-Length: 1043
Connection: Close
Upvotes: 2
Views: 1085
Reputation: 552
I solved this problem! In Web.config turn on authentication section to FormsAuthentication.
Upvotes: 0
Reputation: 11
I resolved this problem! In Web.config turn on authentication section to FormsAuthentication.
This was very helpful. I don't normally post comments, but in this case, I thought it would help others. In my case, the cache-control was set to private, and I could not modify it. The obscure answer was I had authentication turned on, when I didn't need or want it. I will say that it took much longer to get a hint from search engines, maybe this text will help.
Upvotes: 1