Page 1 of 1

AJax and caching

Posted: Mon Apr 07, 2008 12:43 pm
by PeterPHP
Sorry for the long description, I hope you'll read through.

I dynamically want to load data through ajax calls (GET method with params). The data on the server may have changed for the same params or they may have not. If things changed on the server I want the browser to get a fresh copy otherwise use its own browser cached version. I found a good article, which I am trying to implement to achieve the above:http://www.sitepoint.com/article/cachin ... erformance. The thing is, it all works fine in FF but IE7 keeps screwing me over.

Using POST messages will make the browser always go to the server, which is good, but I don't think I can get the browser to use a cached version by returning a header with code 302 Not modified.

The GET messages also give problems in IE7 (not FF as it will go to the server), because it will always use the browser cached version when doing an ajax call with the same params and not even go to my php file which is serving the dynamic data.
Setting the headers telling IE7 not to cache (many posts on that one) works, but then it NEVER uses a cached version.

So, what I am trying to do is use GET ajax calls with params and decide in the PHP file whether to return the full data or return a header with the code 302 Not Modified. How can I get IE7 to always go to my php file and when it gets a 302 make it use its own cached browser copy. I hope it is clear what I mean.

Any help is greatly appreciated as I am banging my head on the wall for a day now.
Thanks for some expert help!