gpt4 book ai didi

javascript - 有没有办法绕过 JavaScript 的缓存?

转载 作者:行者123 更新时间:2023-11-28 16:05:37 25 4
gpt4 key购买 nike

我试图显示我放入 iframe 中的每个源的加载时间:

$.get("text.txt", function (data) {
var array = data.split(/\r\n|\r|\n/)
var beforeLoad = (new Date()).getTime();
var loadTimes = [];

$('#1').on('load', function () {
loadTimes.push((new Date()).getTime());

$('#1').attr('src', array.pop());

$.each(loadTimes, function (index, value) {
var result = (value - beforeLoad) / 1000;
$("#loadingtime" + index).html(result);
});
}).attr('src', array.pop());
});

有没有办法让它不依赖于缓存?

最佳答案

您可以使用 $.ajax 函数的 cache 属性:

$.ajax({
type: 'GET',
url: 'text.txt',
cache: false,
success: function() {
...
}
});

它会自动将时间戳参数附加到您的网址末尾。

关于javascript - 有没有办法绕过 JavaScript 的缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15081951/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com