views:

57

answers:

2

Maybe it has been asked somewhere, but I am trying to find my question and I am not able to find any answer.

Here's my question:

I am developing a web application and because of some major JavaScript issue in IE8, I need the user to run "Google Chrome Frame" (To enhance the speed of the web page). I was impressed that my page was working 100% fine until the time it was supposed to be refreshing and it wasn't refreshing (Ajax getJSON request using jQuery).

The problem is that it does not request the new data on the server, but it looks like it goes in the cache for the answer of that request and then return the same thing every time instead of new data.

I don't really know how to explain it, but it just does not update. Also, when I hit F5 on the page, it does not update the page, it keeps the old page (even if I hit CTRL-F5 or any other normal force-refresh button). To have the changes, I actually need to close the browser (IE8) and re-open it so it can take the new changes.

Is there anyone who know how I could disable the cache when Google Chrome Frame is active?

The meta tag I use is :

<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, must-revalidate"> 
<META HTTP-EQUIV="X-UA-COMPATIBLE" CONTENT="CHROME=1">

If you need any more details, don't hesitate to ask.

A: 

An old CGI trick would have been to encode the date as a parameter onto the request so the URL changes with each request. That generally stops any caching on the URL.

So you'd have url?01102010134532 if you encoded date and time down to miliseconds.

If I understand your requirement properly, you'd have to do this in JQuery / JS and would need to modify the parameter on the URL after each AJAX request was made, so the next one would be different to the previous

Paul Hadfield
I know that trick, you also need to do that in action script (flash) when you do AJAX requests. I know that will work for the Ajax request (like using the tick time), but if my JS file calling my service is updated it won't actually update, because it will still be in cache.
Nordes
The operations should be in memory, so the cache shouldn't come into it. Consider if you had a function mapped to a click event and each time you clicked it added one to the counter and displayed it. If what you are saying is true, the alert would also contain the same value (never increased) as it was always taken from cache. I've never seen that happen before in any situation.
Paul Hadfield
You were right about the cache in AJAX (jquery)... I had to put $(document).ready(function() { $.ajaxSetup({ cache: false }); }); just to make sure that the cache by default was disabled. But it's weird that it was working in all browsers except [IE + GCF]. Anyway, thank you.
Nordes
A: 

This doesn't sound like a browser-specific caching problem at all. Are you setting any of the HTTP headers for your content? I'm guessing not.

http://developer.yahoo.com/performance/rules.html#expires

http://developer.yahoo.com/performance/rules.html#etags

Matt Ball
Yes, I tried, but it seems that Google Chrome Frame override these meta.
Nordes
@Nordes: you can use the dev tools to look at the HTTP headers (since GCF _is_ Chrome). Are the headers that the browser receives the same as what you send? Additionally, are you _only_ setting HTTP headers using `<meta/>` tags? Because it sounds like you're not necessarily setting headers on your JSON responses.
Matt Ball
@Nordes: the "Audits" tag in the Developer Tools window is your friend here.
Matt Ball