Application Cache HTML

发布时间 2023-10-09 16:15:47作者: vx_guanchaoguo0

主要是加速

  • 离线存储,Web 开发者可借助微信提供的资源存储能力,直接从地加载 Web 资源而不需要再从服务端拉取,
  • 从而减少网页加载时间,为微信用户提供更优质的网页浏览体验

使用方式

  • example.appcache
CACHE MANIFEST
# 版本号或注释

CACHE:
index.html
styles.css
app.js

NETWORK:
*

FALLBACK:

  • index.html
<!DOCTYPE html>
<html manifest="example.appcache">
<head>
  <title>Web App with Application Cache</title>
</head>
<body>
<h1>Welcome to the Web App!</h1>
<p>This is a simple example of using Application Cache.</p>

<!-- 其他网页内容 -->

<script src="app.js"></script>
</body>
</html>
  • app.js
const app = 1;

  • styles.css
body{
    background-color: aqua;
}

chrome 不在支持

  • 浏览器版本较新:从 Chrome 版本 80 开始,Application Cache 已被弃用。因此,在较新的 Chrome 版本中,manifest 属性可能不再被支持。