This commit is contained in:
joshen
2025-11-25 18:54:50 +08:00
2 changed files with 33 additions and 25 deletions

View File

@@ -563,22 +563,26 @@ export default {
xmlhttp.abort(); xmlhttp.abort();
}, 5000); }, 5000);
// 1. 拼接随机参数(时间戳+随机数确保URL唯一破缓存 // 1. 拼接随机参数(时间戳+随机数确保URL唯一破缓存
const url = // const url =
window.location.protocol + // window.location.protocol +
"//uapi.boe.com.cn/500.html?t=" + // "//uapi.boe.com.cn/500.html?t=" +
Date.now() + // Date.now() +
Math.random(); // Math.random();
// 2. 打开 HEAD 请求URL已带随机参数 // 2. 打开 HEAD 请求URL已带随机参数
xmlhttp.open("HEAD", url, true); //xmlhttp.open("HEAD", url, true);
// 3. 设置禁用缓存的请求头(覆盖现代浏览器+老IE+代理) // 3. 设置禁用缓存的请求头(覆盖现代浏览器+老IE+代理)
xmlhttp.setRequestHeader( // xmlhttp.setRequestHeader(
"Cache-Control", // "Cache-Control",
"no-cache, no-store, must-revalidate" // "no-cache, no-store, must-revalidate"
// );
// xmlhttp.setRequestHeader("Pragma", "no-cache"); // IE兼容
// xmlhttp.setRequestHeader("Expires", "0"); // 禁止过期缓存复用
xmlhttp.open(
"HEAD",
window.location.protocol + "//uapi.boe.com.cn/500.html",
true
); );
xmlhttp.setRequestHeader("Pragma", "no-cache"); // IE兼容
xmlhttp.setRequestHeader("Expires", "0"); // 禁止过期缓存复用
// xmlhttp.open("HEAD", window.location.protocol + "//uapi.boe.com.cn/500.html", true);
xmlhttp.send(); xmlhttp.send();
xmlhttp.onreadystatechange = function () { xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) { if (xmlhttp.readyState == 4) {

View File

@@ -2000,22 +2000,26 @@
xmlhttp.abort(); xmlhttp.abort();
}, 1000); }, 1000);
// 1. 拼接随机参数(时间戳+随机数确保URL唯一破缓存 // 1. 拼接随机参数(时间戳+随机数确保URL唯一破缓存
const url = // const url =
window.location.protocol + // window.location.protocol +
"//uapi.boe.com.cn/500.html?t=" + // "//uapi.boe.com.cn/500.html?t=" +
Date.now() + // Date.now() +
Math.random(); // Math.random();
// 2. 打开 HEAD 请求URL已带随机参数 // // 2. 打开 HEAD 请求URL已带随机参数
xmlhttp.open("HEAD", url, true); // xmlhttp.open("HEAD", url, true);
// 3. 设置禁用缓存的请求头(覆盖现代浏览器+老IE+代理) // 3. 设置禁用缓存的请求头(覆盖现代浏览器+老IE+代理)
xmlhttp.setRequestHeader( // xmlhttp.setRequestHeader(
"Cache-Control", // "Cache-Control",
"no-cache, no-store, must-revalidate" // "no-cache, no-store, must-revalidate"
// );
// xmlhttp.setRequestHeader("Pragma", "no-cache"); // IE兼容
// xmlhttp.setRequestHeader("Expires", "0"); // 禁止过期缓存复用
xmlhttp.open(
"HEAD",
window.location.protocol + "//uapi.boe.com.cn/500.html",
true
); );
xmlhttp.setRequestHeader("Pragma", "no-cache"); // IE兼容
xmlhttp.setRequestHeader("Expires", "0"); // 禁止过期缓存复用
// xmlhttp.open("HEAD", window.location.protocol + "//uapi.boe.com.cn/500.html", true);
xmlhttp.send(); xmlhttp.send();
xmlhttp.onreadystatechange = function () { xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) { if (xmlhttp.readyState == 4) {