编译资源何时缓存在 Rails 中
当我使用 rake asset:precompile 预编译 Rails 3.1 应用程序的资源时,如果资源文件中没有任何更改,它会输出旧的缓存版本。我可以这么说,因为我的 erb 正在使用一个常量,我试图在应用程序的其他地方更改该常量。一种解决方法是在重新预编译之前更改其中一个 css 文件(例如通过添加空格等),但这很痛苦,如果可能的话,我想尝试禁用此缓存。有什么想法吗???
When I precompile my assets for a rails 3.1 app with rake assets:precompile
it spits out an old cached version if nothing changes in the asset files. I can tell because my erb is making use of a constant that I was trying to change elsewhere in my app. One work around is to alter one of the css files (eg by adding a space etc) before re-precompiling but this is a pain and I would like to try and disable this caching if it is possible. Any ideas???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是管道的预期行为 - 在预编译时仅评估 ERB 一次。编译时的值就是您在文件中获得的值。
缓存基于检查文件的时间戳。您可以在生产中运行 Sprockets,无需预编译(这称为实时编译),但您无法关闭缓存,因为性能会很糟糕 - 每个请求都需要 Sprockets 重新编译所有文件。
对不起 :-(
This is the expected behavior of the pipeline - the ERB is evaluated only once when you precompile. The value at compile time is the value you get in the file.
The caching is based on the checking the timestamp of the files. You could run Sprockets in production without precompiling (this is called live compiling), but you cannot turn off the caching because the performance would be dreadful - every single request would require Sprockets to recompile all the files.
Sorry :-(