I have a Ajax code that calculates the time, the Web Service call took to fetch the data from the datatabse and display it on the GUI [i.e the Turnaround Time] on a respective div/iframe element. But sometimes what I have usually observed is that the time is being cached and even though the total process took around 8.35345 seconds, It actually displays the old time [time it took for the previous request] which was for ex say 9.2 seconds. So is it that the browser is caching my variables or is that a overall Ajax Caching issue. Does someone else also have had the same issue? Does this Book cover Effective strategies of dealing with Caching and improving the cache-hit percentage. Is there a way to stop caching of my data in the browser or is there a way to refresh the stale data and keep it in sync with the new request?
Please suggest so that I could propose the changes to Dev-Team!!
I only ever see this in IE and it's a fairly well known issue if you hit google on it. The solution I use is something like this..
Caveat is this code is Java. You'll need to adjust to your language of choice.
And then forward the request back to the client. The reason you need to do this in code is because IE is actually caching the HTML as a page that comes back so even if you added the meta tags to your HTML page, IE will never see them, as it pulls the cached page rather than the newly acquired page.
Originally posted by Alexei White: This is a uniquely Internet Explorer issue. The solution we prefer is to use the cache-buster technique.. which is to append a unique string to the end of your XHR url for every request. Eg:
By solution, don't you mean hack? This is well documented out in google land as well for dealing with IE caching images that tend to change. You can put a random number on the end of the image src to force IE to recognize it's a new image. The same applies for other types of requests as well, obviously.
I only prefer my suggestion because it's using specifications (yes, even if they are just for IE) to make the browser play nice rather than a hack or trick. But it's purely preference in this case.
Joined: Mar 21, 2006
Cool, I googled my concern and I found the exact same solution as Gregg suggested me, Thanks a ton!!