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

标签 ruby-on-rails-3 memcached page-caching

我在我的 Ruby on Rails 3 应用程序中使用 Memcached。它适用于 Action 和片段缓存,但是当我尝试使用页面缓存时,页面存储在文件系统中而不是 Memcached 中。如何告诉 Rails 也使用 Memcached 进行页面缓存?

在我的 development.rb 文件中:

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

最佳答案

你不能。 memcached 中页面缓存的等价物是 Action 缓存,因为请求必须通过 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 .

关于ruby-on-rails-3 - 使用 Memcached 缓存页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5807798/

相关文章:

ruby-on-rails - 如何将 Mongoid _id 转换为时间戳 (Rails)

google-app-engine - memcache 是否在 go on appengine 中工作?

apache-kafka - 在Kubernetes中运行Kafka时如何管理页面缓存资源

ruby-on-rails - Rails 的页面缓存与 HTTP 反向代理缓存

ruby-on-rails - 如何从 lib 目录中的文件使用路由帮助器方法?

ruby-on-rails - 使用偏执狂的默认范围急切加载已删除的记录

ruby-on-rails - Ruby on Rails 计数器缓存错误

java - Tomcat 7 与 Memcached session 管理器

caching - Infinispan 与 memcached 满足高并发需求

linux - 是否从页面缓存中的脏页面进行文件读取?