如何将缓存清单添加到 Meteor 应用程序? [英] How can I add a cache manifest to a Meteor app?

查看:41
本文介绍了如何将缓存清单添加到 Meteor 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,添加它没有问题,但是我如何生成缓存清单?我需要以某种方式获取 Meteor 生成的组合 CSS 和 JS 的路径.http://www.whatwg.org/specs/web-apps/当前工作/#manifests

Well, adding it will be no problem, but how can I generate the cache manifest? I would need to somehow get the paths to the combined CSS and JS that Meteor generates. http://www.whatwg.org/specs/web-apps/current-work/#manifests

推荐答案

更新:

正如 user1506145 所说:

As user1506145 said:

meteor add appcache

https://atmospherejs.com/meteor/appcache

此答案已过时:

答案在于 bundler 包,我在那里自动生成了一个清单文件.您可以通过挂钩到:bundle.cssbundle.js.client

The answer lies in the bundler package, I autogenerated a manifest file there. You can get a full list of css and js files by hooking into: bundle.css and bundle.js.client

一旦您设法为他们获取清单文件,您将需要使用您生成的清单内容变量执行以下操作(不要忘记从缓存所有需要的流星网址中排除):

Once you have managed to get them a manifest file you will need to do the following with a manifestcontent var you have generated (dont forget to exclude from caching all the meteor urls needed):

buffer.files.client_cacheable['manifest.appcache'] = new Buffer(manifestcontent);

这将使您的应用程序为 appcache 文件提供服务.然后你可以编辑/app/lib/app.html.in 来添加引用.

This will have your application serving the appcache file. Then you can edit /app/lib/app.html.in to add the reference in.

我这样做时遇到的问题是我无法经常使缓存失效,因此最终导致应用程序在从服务器重新加载时出现问题.

My issue when I did this was that I wasn't able to stale the cache often enough so it ended up with an application messed up on reload from the server.

这篇关于如何将缓存清单添加到 Meteor 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆