是否可以在白金服务工作人员上进行dom

编程入门 行业动态 更新时间:2024-10-21 10:30:57
本文介绍了是否可以在白金服务工作人员上进行dom-repeat?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想为用户提供通过分组(书籍的类别,个别书籍,或者如果他们不希望整本书的某些章节,甚至只是章节)来缓存多达2600多个项目的功能.据我所知,不可能对所有这些项目进行预缓存,因为其中有2600多个,并且将来还会更多-服务工作者将超时几百次.而且由于服务人员在安装时要么全部获得要么一无所获(如果我理解正确),我是否需要使用多个服务人员(具有不同的ID?),还是我在考虑这个错误? ?

I want to provide a user the ability to cache up to 2,600+ items, by groupings (categories of book, individual books, or possibly even just chapters of a certain book if they don't want the whole book). It is not possible, as far as I can tell, to precache all of these items because there are 2,600+ of them, and will be more in the future - the service worker will timeout with under a couple hundred. And since service workers either get all or none on install (if I understand correctly), do I need to use multiple services workers (with different ids?), or am I thinking about this wrong?

我在想什么...

<iron ajax></iron-ajax> <template is="dom-repeat" items="..."> <platinum-sw-register auto-register clients-claim skip-waiting> <platinum-sw-cache default-cache-strategy="fastest" cache-config-file="../someGenerator.php"></platinum-sw-cache> </platinum-sw-register>

换句话说:

  • 通过iron-ajax获取所需的URL列表(基于用户启用缓存的内容)
  • 通过dom-repeat遍历URL作为组
  • 使用URL组的自定义缓存配置创建服务工作者
  • 重复2和3直到完成,然后举杯祝酒
  • someGenerator.php将为特定的URL组返回JSON配置设置.

    That someGenerator.php would return a JSON config setup for the particular group of URLs.

    我的应用程序是一个单页应用程序-带有霓虹动画页面-一页代表类别,一页代表图书清单,一页代表每本书的目录,然后每章内容之一.所有数据都是通过Iron-ajax获取的.

    My app is a single page app - with neon-animated-pages - one page representing categories, one for book listings, one for table of contents for each book, and then one of each the chapter contents. All of the data is obtained via iron-ajax.

    以下是一些说明问题的链接:

    Here are some links to demonstrate the issues:

    该应用

    生成的大型非功能性缓存配置

    我怀疑,为了不因冗余而导致服务人员错误或覆盖现有缓存,我将需要分配单独的ID,并将其包含在生成的缓存配置中. 听起来不错吗?

    I suspect, in order to not have service workers errors due to redundancy, or overwrite existing caches, I will need to assign individual ids, and include them in the generated cache-configs. Does that sound right?

    推荐答案

    不,我认为这不是正确的方法. <dom-repeat>并创建多个服务人员无法完成您想要的事情.

    No, I don't think that's the right approach. <dom-repeat> and creating multiple service workers isn't going to accomplish what you want.

    由于在获取JSON配置和执行所有预缓存方面的延迟,您的确在install处理程序中遇到了一些服务工作者施加的超时.退后一步,确定要整套URL预先缓存吗?

    It does look like you're bumping into some service worker-imposed timeouts during your install handler due to the delays in fetching the JSON configuration and performing all of the precaching. Taking a step back, are you sure that you need that entire set of URLs precached?

    <platinum-sw>还将为您提供运行时缓存,以便在有可用的网络连接时浏览器加载给定URL时,资源将自动添加到缓存中,并在后续回访期间脱机使用.

    <platinum-sw> will give you runtime caching as well, so that when a browser loads a given URL when there's a network connection available, the resources will be automatically added to the cache and available offline during subsequent return visits.

    还有其他方法可以使用window.caches从受控页面内缓存资源,也可以使用 postMessage() ,以传达其他URL列表,以从受控页面缓存到服务工作者.这两种方法都涉及超越使用<platinum-sw>获得的默认功能,并稍微深入研究内部.

    There are other approaches that would use either window.caches to cache resources from within your controlled page, or using something like postMessage() to communicate a list of additional URLs to cache from your controlled page to your service worker. Both of those approaches would involve going beyond the default functionality you get from using <platinum-sw> and digging into the internals a bit.

    更多推荐

    是否可以在白金服务工作人员上进行dom

    本文发布于:2023-08-02 11:32:04,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1277457.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:白金   工作人员   dom

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!