Reputation: 514
We developing Web Application using MVC4 and Jquery Mobile. Our requirement is to cache all images , jquery , css. So i triew below code which works like charm.
<staticContent>
<clientCache cacheControlMaxAge ="2.00:00:00" cacheControlMode="UseMaxAge" />
</staticContent>
In my visual studio its work great. I can able to capture all images,script.
But when i deployed in IIS8 cache not working. I tried lot but no luck. Please guide me. Why cache is not work when deployed in IIS.
Iam using IIS8.The one thing i noticed is if i browse from IIS by clicking deployed website it get cached everything. but if typed url like 10.111.151.88:8002 is not caching in the browser.
Upvotes: 1
Views: 1207
Reputation: 514
Atlast i found answer guys. The problem is i had below code in global.asax
protected void Application_BeginRequest()
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
}
it deleting all my cache and making browser not to cache anything.
Upvotes: 2
Reputation: 27944
You have added almost no information on you IIS configuration. The following guide will probably help to find your missing configuration: Configure IIS Client Cache < clientCache >
I guess you have missed something in the Set Common HTTP Response Headers.
Upvotes: 1