【问题标题】:Rails 3 fragment caching not doing anythingRails 3片段缓存没有做任何事情
【发布时间】:2011-11-28 20:14:06
【问题描述】:

尝试让片段缓存在 Rails 3.0.9 中工作。

我已经在 development.rb 中设置了这个:

config.action_controller.perform_caching = true

并重新启动服务器(webrick)。然后在我看来设置这个:

<% cache("tags_json") do %>
    [Content to be cached]
<% end %>

当我重新加载页面时,我在日志中看不到任何关于缓存的内容。再次重新加载页面,结果相同,没有写入或读取缓存。据我所知,文件树中的任何地方也没有创建缓存文件。

我是缓存新手,所以我确定我只是忘记设置一些东西。任何帮助表示赞赏,谢谢!

【问题讨论】:

  • 你的 tmp/cache 目录下有文件吗?
  • 没有。抱歉这么久才回复。

标签: ruby-on-rails ruby-on-rails-3 caching


【解决方案1】:

除了配置 ActionController 的缓存执行外,您还需要在通用配置中设置缓存存储。 放

config.cache_store = xyz,abc

cache_store 配置用于 Rails 缓存的缓存存储。选项包括符号之一 :memory_store、:file_store、:mem_cache_store 或实现缓存 API 的对象

如果目录 tmp/cache 存在则默认为 :file_store,否则默认为 :memory_store。 我会推荐使用dalli store in-conjunction with memcached client。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-27
    • 2012-09-07
    • 2016-10-02
    • 2013-09-28
    • 1970-01-01
    相关资源
    最近更新 更多