Reputation: 17430
I develop a simple overlay to preview image in full size.
I use "cache: false" to prevent caching.
The code is simple:
$.ajax({
url: urlFull,
cache: false,
success: function(html){
// display image
},
error: function(XMLHttpRequest, textStatus, errorThrown ) {
// display error
}
});
The problem is - When image file will be replaced by another, browser will always show the old one, regardless of "cache: false" option was set.
This issue appears under Safari 5.0 (6533.16) and Chrome 5.0.375.99.
In Firefox 3.6.3 it works as expected (no caching)
I cannot control server-side logic, because i preload a regular file, without calling controller actions in rails.
Is there any workaround of this problem ? Maybe, i can intercept the response with Rails server and tweak some headers ? ... I developing under localhost.
Thanks.
Upvotes: 1
Views: 1018
Reputation: 17430
I have tried to use
data: { timestamp: new Date().getTime() }.
It does not work.
In developer's panel of Safari i found, that the request string looks like this:
I have added the "_" parameter:
data: {_: new Date().getTime()}
and got following url:
"http://path_to_the_image.png?=1279789134612&=1279789245466".
Also, i have tried to use "timestamp", "tstamp", "t"; setting "0", "9999999999999" ... all gives no result...
It seems, like i cannot control the timestamp, that internally is setted in $.ajax ...
Upvotes: 0
Reputation: 37019
As a "dirty" solution try adding a time-stamp to your URL GET parameters.
Upvotes: 1