user279521
user279521

Reputation: 4807

Why is caching such an issue in .net 3.5?

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?

Upvotes: 1

Views: 116

Answers (1)

Cheeso
Cheeso

Reputation: 192597

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.

Upvotes: 1

Related Questions