jQuery的(或者浏览器)的缓存破AJAX加载脚本 [英] jQuery (or maybe the browser) is cache-breaking ajax loaded scripts
问题描述
我加载通过一个视图页面 $。阿贾克斯()
使用jQuery调用。我明确地设置了高速缓存选项设置为true。无处在应用程序中,我们使用 $。ajaxSetup()
来另行指定。
I'm loading a view page via an $.ajax()
call with jQuery. I'm explicitly setting the "cache" option to true. Nowhere in the application are we using $.ajaxSetup()
to specify otherwise.
下面是Ajax请求设置:
Here's the ajax request setup:
$(".viewDialogLink").click(function() {
$.ajax({
url: $(this).attr("href"),
dataType: "html",
type: "GET",
cache: true,
success: function(data) { $("#dlgViews").html(data).dialog("open"); }
});
return false;
});
的响应返回成功。打开对话框,有些内容显示。
The response comes back successfully. The dialog opens, and some content displays.
然而的
HOWEVER
有在返回的HTML脚本标记。例如:
There are script tags in the returned html. For example:
<script type="text/javascript" src="http://../jsapi/arcgis/?v=1.4"></script>
现在 - 在响应文本,这些看起来正常。但对于这些脚本从萤火看到的实际的浏览器请求,的包括在查询字符串的缓存断路器参数。它们看起来像:
Now - in the response text, these look normal. But the actual browser requests for these scripts, as seen from FireBug, include a cache-breaker parameter in the query string. They look like:
http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.4&_=1264703589546
。
没有在加载HTML中的其他资源 - CSS或图像 - 包括高速缓存断路器在他们的要求
None of the other resources in the loaded html - css or images - include the cache breaker in their request.
这是怎么回事?如何打开这个缓存断路器了吗?
What is going on? How do I turn this cache breaker off?
推荐答案
我能我的测试服务器上复制您的问题。我再从jQuery的1.3.2变更为1.4.1。与jQuery 1.4.1它不添加缓存破字符串。
I was able to replicate your issue on my test server. I then changed from jquery 1.3.2 to 1.4.1. With Jquery 1.4.1 it doesn't add the cache-breaking string.
<script type="text/javascript" src="jquery-1.4.1.min.js"></script>
当然,使用1.4.1可能不适合你的选择。
Of course, using 1.4.1 might not be an option for you.
这篇关于jQuery的(或者浏览器)的缓存破AJAX加载脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!