繁体   English   中英

服务工作者缓存需要时间来响应延迟

[英]service worker cache takes time to respond with latency

这是我第一次使用服务工作者缓存一些东西的交互。 作为我的POC的一部分,我试图缓存像“js”,“css”这样的资产,

我正在使用sw-toolbox

 (function (global) { 'use strict'; // Ensure that our service worker takes control of the page as soon as possible. global.addEventListener('install', function (event) { return event.waitUntil(global.skipWaiting()); }); global.addEventListener('activate', function (event) { return event.waitUntil(global.clients.claim()); }); // The route for any requests from the googleapis origin toolbox.router.get('/(.*)', global.toolbox.cacheFirst, { cache: { name: 'modjs', maxEntries: 30, maxAgeSeconds: 86400 }, debug: true, origin: /\\.abc\\.com\\:8044$/ }); })(self); 

我可以看到网络呼叫来自服务工作者,但他们仍然显示出一些延迟。 在此输入图像描述

我有什么不对?

为了获得更好的页面呈现性能,请尝试在.js文件之后链接.css文件。 检查文件的顺序。 还要确保用户有权访问脚本文件。 该项目可能使其web.config拒绝匿名用户访问。

低音Uncaught ReferenceError ReferenceError意味着您正在尝试访问尚未定义的变量或函数。

有关详细信息,请查看此文档: https//developers.google.com/web/showcase/2015/service-workers-iowa#top_of_page

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM