我有一个 Vue.js 应用程序,我目前正在使用工作箱进行缓存,因此它可以脱机工作。但是,视频似乎在 Safari 中不起作用。
我已经研究过,所有迹象都指向这一点: https ://developers.google.com/web/tools/workbox/guides/advanced-recipes#cached-av
但这似乎对我不起作用。
这是我的代码:
网页包
configureWebpack: {
plugins: [
new InjectManifest({
swSrc: './src/sw.js',
swDest: "sw.js",
maximumFileSizeToCacheInBytes: 5000000000
})
]}
sw.js(服务工作者)
import { skipWaiting, clientsClaim } from "workbox-core";
import { precacheAndRoute } from "workbox-precaching";
import { registerRoute } from "workbox-routing";
import { CacheFirst } from "workbox-strategies";
import { CacheableResponsePlugin } from "workbox-cacheable-response";
import { RangeRequestsPlugin } from "workbox-range-requests";
registerRoute(
({ url }) => url.pathname.endsWith(".mp4"),
new CacheFirst({
plugins: [
new CacheableResponsePlugin({ statuses: [200] }),
new RangeRequestsPlugin()
]
})
);
skipWaiting();
clientsClaim();
precacheAndRoute(self.__WB_MANIFEST);