Heroku Rails 3 all.css/all.js 动态生成?
我目前正在努力解决 Heroku 上 Rails 2 升级到 3 应用程序上的大量 all.js / all.css 缺失的问题。我不希望每个请求有十几个样式表链接,也不希望静态捆绑 -> s3 文件作为部署的一部分。
这似乎是一个熟悉的问题,准备一些特定于 url 的内容并将其发送回浏览器。
有没有人考虑过让 Rails 即时生成这些文件并使用 varnish 来缓存它们(因为它在重新部署时被清除,此时 css/js 文件将被清除),而不是使用外部捆绑应用程序作为部署脚本等的一部分。改变)?
我的问题是这是否已经完成&我只是没能用谷歌搜索它,或者如果这听起来像一个愚蠢的想法,为什么?
I'm currently wrestling with a lot of all.js / all.css missing hits on a rails 2 upgraded to 3 app on Heroku. I'd prefer not to have a dozen or so stylesheet links per request, and also don't want to statically bundle -> s3 the files as part of the deploy.
This seems like a familiar problem, preparing some content specific to a url and sending it back to the browser.
Rather than using an external bundling app as part of a deploy script etc, has anyone considered having rails generate these files on-the-fly and use varnish to cache them (since it's cleared on redeploy, which is when the css/js files would change)?
My question is whether this has been done already & I just failed to google it, or if it sounds like a dumb idea, why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更好的是:Rails 3.1 资产管道正是这样做的,Heroku 会为您处理预编译和缓存。
Even better: Rails 3.1 asset pipeline does exactly this, and Heroku handles precompilation and caching for you.