Ryder
Ryder

Reputation: 514

Caching not working when deployed in IIS8

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

Answers (3)

Ryder
Ryder

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

Jamie
Jamie

Reputation: 864

Is static and dynamic compression enabled in IIS8?

Upvotes: 1

Peter
Peter

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

Related Questions