【发布时间】:2021-07-14 12:52:24
【问题描述】:
我开发了一个应用程序,但是当我从应用程序推送最新版本到服务器时,CSS 和 JS 文件没有更新。旧文件正在显示。更新文件后如何清除缓存?
像 jcubic 一样编辑
现在我就是这样使用破坏者的。
index.html:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AIS</title>
<script src="index.php"></script>
<link rel="stylesheet" href="<?= with_hash('style.css') ?>">
</head>
index.php:
<php?
function with_hash($url) {
return $url . "?" . md5(file_get_contents($url));
}
?>
错误信息:
Refused to apply style from 'http://127.0.0.1:5500/%3C?=%20with_hash(%27style.css%27)%20?%3E' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
【问题讨论】:
-
PHP 代码在 html 文件中不起作用。请将扩展名更改为 php。
标签: javascript html jquery css caching