views:

50

answers:

1

Has anyone else having an issue with browser caching when using .net? I am using VS 2008 and IE8. And I include all the recommended code to ensure that there is no caching, still 20% of the time, I get cached values. This was never an issue with classic asp. Any ideas?

+1  A: 

If you want to insure you get fresh results, append a nonce to the query string, or, if there is no query string, introduce one, that contains a nonce.

Instead of requesting http://foo/bar.htm , request http://foo/bar.htm?_=4944994230.

This works with static content or dynamically-generated content. You can name the parameter anything. In this case I just used an underscore. Just be careful to not duplicate the name of a querystring param that is used by the actual application.

To make it transparent, you can do this in browser-script, in the click event of a button before submitting a form. This is how jQuery implements its "do not use cache" option for ajax requests.

Cheeso