简体   繁体   中英

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.

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.

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.

在IIS8中是否启用了静态和动态压缩?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM