详细解读Rails Caching

豆豆网   技术应用频道   2008年01月18日  【字号: 收藏本文

本文详细介绍详细解读Rails Caching

  问题出现:

  I am trying to use caches_action and the agile book says that it is keyed

  off the URL, however it does not seem to pick up the URL parameters.

  http://localhost:3000/controller/action/id?foo=bar

  and

  http://localhost:3000/controller/action/id?foo=foobar

  Returns the same page.

  问题原因:

  Rails Caching不能Cache Parameter,所以caches_action时会出现上述原因。

  解决方法:

  1. 修改rails routes.rb,将原来的”?parameters=”的调用方式更改为/action/:parameters的访问方式,以使用rails cache不同的fragment

  2. 安装一个rails-caching的plugin,然后修改environment.rb中增加cache key for action : Action Cache Update Plugin

责编:豆豆技术应用

正在加载评论...