0

I'm using IIS 7.5 and I'm wondering if I should disable client side caching. Are my ASPX pages cached by the browser / client with default ASP.Net / IIS settings?

Are there any browsers that require me to disable client caching? My aspx pages should never return a '304 Unmodified'.

Kees C. Bakker
  • 32,294
  • 27
  • 115
  • 203
  • you MUST read this one: http://msdn.microsoft.com/en-us/library/06bh14hk(v=vs.100).aspx there are specific ASP.NET directives to instruct IIS/Browser how to handle page level caching... – Davide Piras Jan 23 '12 at 15:10
  • @DavidePiras yeah, I know there are. But I would like to know default behaviour of browsers, that's not within the scope of the document, is it? – Kees C. Bakker Jan 23 '12 at 15:12
  • 2
    check this question and answer: http://stackoverflow.com/a/956000/559144 – Davide Piras Jan 23 '12 at 15:14
  • possible duplicate of [Browser Caching in ASP.NET application](http://stackoverflow.com/questions/955792/browser-caching-in-asp-net-application) – jrummell Jan 23 '12 at 15:20
  • @jrummell the question you've mentioned has to do with static content. I'm talking about dynamic content and possible client caching. – Kees C. Bakker Jan 23 '12 at 15:56
  • I once had some problems with IE which due to poor connection (I think it was going offline), didn't load the new page and only displayed one from cache – mslliviu Jan 23 '12 at 16:02
  • 1
    The browser doesn't know or care that the page is a "dynamic" .aspx file. It only knows that it's content is html. – jrummell Jan 23 '12 at 16:11
  • @jrummell true, so IIS should instruct the browser not to cache. What does it instruct by default? – Kees C. Bakker Jan 23 '12 at 16:14
  • 1
    I'm not 100% sure, but I don't think any expires headers are added by default, and therefore its up to the browser to decide based on its defaults. This answer may be helpful: http://stackoverflow.com/a/918346/26226 – jrummell Jan 23 '12 at 16:24

2 Answers2

0

You don't have to change anything in IIS, asp.net gives you all the control you need over caching from inside your application code and webconfig files. If you don't change anything, you don't have to worry about users seeing old pages if you didn't write the code for that yourself.

EPLKleijntjens
  • 916
  • 1
  • 8
  • 21
  • So by default no aspx pages are cached on the client? – Kees C. Bakker Jan 23 '12 at 15:56
  • I think @EPLKleijntjens might be referring to server side caching. – jrummell Jan 23 '12 at 16:12
  • I believe that by default there will be no client side caching, but in theory it's possible that asp.net automatically enables a page to be cached by the browser and intelligently sends a 304 response when appropriate. I haven't tested this, so I'm not sure about this, however, the fact remains that when you change anything in your aspx file, asp will know and act accordingly. So there is no need to worry about users seeing old pages. – EPLKleijntjens Jan 23 '12 at 16:32
0

Several comments here asked about client caching defaults.

The problem is that in absence of your application specifically stating whether a given page is cacheable or not you are at the mercy of whatever the browser settings may be.

Some people configure their browsers to cache all content, some are set to look for the headers that come back when requesting a page to determine if it wants to do a full request. Other people have their browsers set to never cache anything local.

All of that said, most browsers are set to cache... sometimes. It doesn't matter what the extension is (html/aspx/whatever). It's all about the content: html, images, etc and what response your browser gives when a given resource is requested.

Now, if you do not want your site files cached then you should make the appropriate settings in your application to enforce this. This way you can override whatever behavior a particular client's browser is set for.

NotMe
  • 87,343
  • 27
  • 171
  • 245