dragonfly
dragonfly

Reputation: 17773

Browser is caching AngularJS views when used with ASP .NET MVC4 & IIS6

I'm using AngularJS on client side and ASP .NET MVC4 as a framework. Application is hosted on IIS6. Unfortunately after each release I get feedback that some pages don't work. I turned out that AngularJS requests for views, eg.

/AppName/Home/Index

are returning 304 status code (I have no idea why...) and browser is using old template. Only hard refresh (ctrl + f5) helps.

Is there a way to configure IIS6 or ASP .NET MVC4 or change web.config in order to prevent browser from caching the views?

Upvotes: 0

Views: 724

Answers (1)

Nick
Nick

Reputation: 798

Try to mark actions for views that you dont want to cache with OutputCache attribute like this:

 [OutputCache(NoStore = true, Duration = 0, VaryByParam = "None")]

It will disable MVC lavel cache. After that browser can still keep some cache. To prevent this try to use something like this.

Upvotes: 1

Related Questions