加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails-3 – 使用Memcached进行页面缓存

发布时间:2020-12-17 02:52:16 所属栏目:百科 来源:网络整理
导读:我在 Ruby on Rails 3应用程序中使用Memcached.它适用于动作和片段缓存,但是当我尝试使用页面缓存时,页面存储在文件系统中而不是存储在Memcached中.如何告诉Rails也使用Memcached进行页面缓存? 在我的development.rb文件中: config.action_controller.perf
我在 Ruby on Rails 3应用程序中使用Memcached.它适用于动作和片段缓存,但是当我尝试使用页面缓存时,页面存储在文件系统中而不是存储在Memcached中.如何告诉Rails也使用Memcached进行页面缓存?

在我的development.rb文件中:

config.action_controller.perform_caching = true
config.cache_store = :mem_cache_store

解决方法

你不能. memcached中的页面缓存等效于动作缓存,因为必须通过Rails提供请求.页面缓存旨在绕过Rails,因此数据必须存储在可以从服务器提供的文件中,如Nginx或Apache.页面缓存如此之快的原因是它完全绕过了Rails.以下是Rails文档所说的内容:

Page caching is a Rails mechanism
which allows the request for a
generated page to be fulfilled by the
webserver (i.e. apache or nginx),
without ever having to go through the
Rails stack at all. Obviously,this is
super-fast. Unfortunately,it can’t be
applied to every situation (such as
pages that need authentication) and
since the webserver is literally just
serving a file from the filesystem,
cache expiration is an issue that
needs to be dealt with.

您可以在here找到更多信息.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读