简体   繁体   English

Firefox和IE图像缓存

[英]Firefox and IE image cache

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? 我在使用firefox和缓存方面有些麻烦,在我的网站上,用户可以使用表单进行查询,此查询会返回一张图片,但根据选择的单选按钮,它会返回不同的图片,它就像在chrome上一样工作,但是在IE和firefox中,总会返回相同的图像,只有当我重新打开浏览器时它才会改变,你能不能给我一些关于如何使它工作的信息?

Thanks to everyone, i solved my problem by putting and unique url each time i made the ajax call. 感谢大家,每次进行ajax调用时,我都会通过put和unique url来解决我的问题。

    <?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>

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. 我在查询字符串中传递一个任意值,类似于GUID或日期时间戳。 This will force a fresh load as the URL will be unique. 这将强制重新加载,因为URL将是唯一的。

I use ASP.NET MVC which I then set a optional parameter in my route, which the controller method ignores. 我使用ASP.NET MVC,然后在我的路由中设置一个可选参数,控制器方法忽略该参数。 I then set my URL via JavaScript: 然后我通过JavaScript设置我的URL:

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. 但是,它应该得到重点。

在Firefox中进行私密浏览,看看图像是否成功更改,问题在于缓存内存还是代码

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. 这将禁用缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM