Reputation: 1597
I'm having some trouble with the firefox and ie cache, on my website the user can make a query with a form, and this query returns a picture, but depending on which radio button is selected, it'll return a different picture, and it works just like that on chrome, but in IE and firefox, the same image is always returned, it only changes when i reopen the browser, can you guys give me some light on how to make this work?
Thanks to everyone, i solved my problem by putting and unique url each time i made the ajax call.
<?php $date = date("H:i:s");
echo '<a href="web/WEB-INF/classes/lineChart.php?id='.$date.'" title="Chart" class="chart">'; echo '<img src="web/WEB-INF/classes/lineChart.php?id='.$date.'" alt="">' ?></a>
Upvotes: 3
Views: 1446
Reputation: 727
Given a unique can be the solution, but you have to watch the length in the string can keep growing, now, you can use this option at the begining of your code
$.ajaxSetup({ cache: false });
this will disable caching.
Upvotes: 0
Reputation: 12064
do private browsing in Firefox and see if image is changes successfully and problem is with cache memory or with the code
Upvotes: 0
Reputation: 38553
Not sure the language you are using to code with, but regardless I am sure the strategy will work across the board. I pass an arbitrary value in the query string, something like a GUID or the datetime stamp. This will force a fresh load as the URL will be unique.
I use ASP.NET MVC which I then set a optional parameter in my route, which the controller method ignores. I then set my URL via JavaScript:
d = new Date();
$('.thumbnail').attr('src', $('.thumbnail').attr('src') + d.getTime());
The solution I needed was unique, so this is probably not similar to what you are trying to resolve. However, it should get the point across.
Upvotes: 2