是否可以使用cache.manifest 离线配置Sinatra .erb 模板?

发布于 2024-11-15 22:18:42 字数 193 浏览 3 评论 0原文

我浏览了网络上的各种帖子;但看起来这仅适用于静态 .html 文件。 Mephisto 和rack-offline 看起来很有用,但我不知道它们是否可以帮助处理 sinatra 模板。

我的views/index.erb有3个get do's - /part1、/part2、/part3,它们保存html输出;如果它们可以离线缓存就太好了。有什么指点吗?

I've looked around at various posts on the web; but it looks like it's all only for static .html files. Mephisto and rack-offline looked like they could be useful, but I couldn't figure out if they could help with sinatra templates.

My views/index.erb has 3 get do's - /part1, /part2, /part3 which hold html output; would be great if they could be cached for offline. Any pointers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆で 2024-11-22 22:18:42

我会尽力回答你的问题。我猜想“我的views/index.erb有3个get do's”,你的意思是你的应用程序中有三个路由,/part1/part2/part3 分别。这三个路由使用 ERB 模板进行处理并返回 HTML。现在您想将它们放入缓存清单中以供离线使用。

首先:对于客户端来说,URL 后面的资源是动态生成的还是静态文件并不重要。您只需将 part1 (注意缺少的斜杠)放入清单中即可完成。

其效果是客户端仅请求 /part1 一次,然后使用缓存的版本,直到您更新清单。

问题是:如果您处理 ERB 模板,则响应中显然会包含一些动态内容。这就是为什么我不明白您为什么要缓存响应。

不要误会我的意思:您可能有充分的理由这样做。我不明白为什么您不能将动态资源的路由放入缓存清单中。

I'll try to answer your question as best I can. I guess with "My views/index.erb has 3 get do's", you mean you have three routes in your application, /part1, /part2, and /part3, respectively. Those three routes are processed using ERB templates and return HTML. Now you'd like to put them into a cache manifest for offline use.

First of all: For the client, it doesn't matter if the resource behind a URL is generated dynamically or if it is a static file. You could just put part1 (notice the missing slash) into your manifest and be done.

The effect would be that a client requests /part1 just once, and then use the cached version until you update your manifest.

Here's the catch: If you process ERB templates, you obviously have something dynamic in the response. And that's why I don't get why you'd want to cache the response.

Don't get me wrong: There might be perfectly good reasons why you want to do this. And I don't see any reason why you can't put routes to dynamic resources into your cache manifest.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文