是否可以以编程方式清除Rails 3布局和视图缓存? [英] Is it possible to programmatically clear Rails 3 layouts and views cache?

查看:78
本文介绍了是否可以以编程方式清除Rails 3布局和视图缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于Rails 3的CMS,允许用户创建和修改布局和视图.这些布局和视图与框架中内置的布局和视图相同,仅由模型支持以提供一些其他功能.我要解决的问题是,一旦在公共端访问这些模板文件,就会立即对其进行缓存,因此除非重新启动服务器,否则无法查看布局或视图中的更改.在禁用了缓存的开发模式下不会发生这种情况,但是显然在生产环境中关闭模板缓存不会对性能产生很大的影响.清除记忆快取似乎并不能解决问题.是否可以以编程方式清除生产中的布局和视图缓存,也许可以使用诸如reload之类的东西!就像我们在控制台上一样?还是我每次有人想要调整以下布局或视图之一时都必须重新启动乘客"(也许使用此线程中的方法:

I have a Rails 3 based CMS that allows users to create and modify layouts and views. These layouts and views are the same ones built into the framework, only backed by a model for some additional capabilities. The problem I would like to address is that these template files are cached as soon as they are accessed on the public end, so it is not possible to see changes in the layouts or views unless the server is restarted. This does not occur in development mode where caching is disabled, but obviously turning off template caching in production wouldn't be great for performance. Clearing memcache doesn't seem to do the trick. Is it possible to programatically clear out the layouts and views cache in production, perhaps with something like reload! like we have in the console? Or am I stuck having to restart Passenger every time someone wants to tweak one of these layouts or views (perhaps using the approach in this thread: Rails Cache Clearing)?

请注意,我并不是指清除公共页面所依赖且正常工作的页面和操作缓存.

Please note that I am not referring to clearing the page and action caches, which the public pages rely on and works just fine.

推荐答案

此配置可能会有所帮助(至少对我有用*):

this configuration may help (at least it worked* for me):

config.action_view.cache_template_loading = false

  • 在Rails 3中工作
  • rails 2略有不同:

    There's just a slight difference in rails 2:

    config.action_view.cache_template_reloading = false
    

    这篇关于是否可以以编程方式清除Rails 3布局和视图缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆