是否可以使用cache.manifest 离线配置Sinatra .erb 模板?
我浏览了网络上的各种帖子;但看起来这仅适用于静态 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会尽力回答你的问题。我猜想“我的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.