tags:

views:

90

answers:

2

We are seeing some odd errors when our customers test our ASP.NET web apps. There is a cart counter on the top of every page that tells you how many items are in the shopping cart. She reports that this number is changing as she moves from one page to the next. We cannot recreate this.

Is it possible that her corporate proxy server is caching the whole page and never actually contacting our server? This is a staging site on http, her production site is on https.

Revision: The page gets cached over HTTPS as well. It shows a completely cached version of our shopping cart page. If the user clicks the refresh button they get a current version of the page, but that new version becomes the cached version.

+3  A: 

It's certainly possible that an intermediate proxy (corporate or otherwise) is caching your pages. Although I don't understand how that would explain the cart number on the page changing. If you don't want any caching to take place, send the appropriate HTTP headers along with each request you don't want cached:

Cache-Control: private, no-store, max-age=0
Expires: <some date in the past>
Pragma: no-cache

The first line above is for HTTP 1.1 clients, and the second 2 are for HTTP 1.0 clients. Check out section 14.9 of the HTTP 1.1 protocol spec for all the gory details.

Asaph
Does a proxy have to obey the HTTP expires header?
Dominic Rodger
It's a bug if they don't since these values are meant to control proxy behavior.
Aaron Digulla
@Dominic Rodger Yes, if it's following the spec. But it is an honor system :( Odds are though, you're not dealing with an evil proxy :)
Asaph
A proxy server can ignore the expire times if they want. Some are by design others are by configuration.
Matthew Whited
Also I have had proxy servers even return a page result back to the wrong session. It is typically caused by not having the no-cache values set. (most proxy servers assume that cached results can return to any user/session)
Matthew Whited
Okay, so it sounds to me like I need to always specify the dynamic content in my site by using the settings above.I suspect we have never had this problem before because the production site is 100% https so the proxy server would be unable to cache.
JoshBaltzell
@Matthew Whited your "pages returned for the wrong session" problem is most likely solved by the Cache-control: private header.
Asaph
most likely but it wasn't my site. I was the network admin of the proxy server trying fix an external site.
Matthew Whited
This information was great, but the other answer fixed my problem. Thanks so much for the answer!
JoshBaltzell
+1  A: 

There's also a setting in IE that could cause this behavior. Go to "Tools" > "Internet Options". On the "General" tab, click "Settings" under "Browsing History". Make sure "Check for newer versions of stored pages" is set to "Automatically". This is the default value.

I had a user who changed this to "Never" and was wondering why he always saw old content. :)

David
I just emailed the client to see if this is the problem. I could recreate this problem by changing this setting on a machine with IE6. Good idea!
JoshBaltzell
This was exactly the problem. The user had their IE set to never get a new version of a web page. Why it was set that way, I may never know.Thanks a lot for the information. This surely saved me many hours of work.
JoshBaltzell