告诉 Rails 缓存静态文件组
是否可以在无需访问网站的情况下告诉rails一起执行application.html.erb页面中所有文件的缓存?
我的页面中有以下代码:
<%= stylesheet_link_tag 'reset','forms','layout','common','pages', :cache => '_cached'%>
当网站首次在生产模式下加载时,这会将所有内容组合到一个 _cached.css 文件中。但是,我希望在网站初始化后重新生成该文件。
因此,步骤是
- 启动 Rails 应用程序
- ,删除现有的 _cached.css 文件,
- 告诉 Rails 根据 application.html.erb 文件网站中的代码重新创建该文件
- ...
有关如何执行此操作的任何想法吗?可以作为 rake 命令还是其他命令?
Is it possible without having to access the website to tell rails to perform a cache of all the files within the application.html.erb page together?
I have the following code in my page:
<%= stylesheet_link_tag 'reset','forms','layout','common','pages', :cache => '_cached' %>
This will combine everything together into a _cached.css file when the website is loaded for the first time in production mode. However, I would like for the file to be regenerated once the website is initialized.
So the steps would be
- start the rails app
- remove the existing _cached.css file
- tell rails to recreate the file based on the code within the application.html.erb file
- website is live...
Any ideas on how todo this? Can be down as a rake command or something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在设置了在网站加载后访问网站文件的 rake 任务后,这就可以了。
After setting up a rake task that accesses the website files once the website is loaded, this works.
将其放入 lib/tasks/ 文件中:
然后将其作为部署脚本或 capistrano 配方的一部分进行调用:
Put this in a lib/tasks/ file:
and then call it as part of your deployment script or capistrano recipe: