---
title: "Rails page cache & will_pagination"
author: "jacky"
date: "2008-07-28T23:34:05Z"
tags: ["Cache", "Rails", "Ruby", "lighttpd", "应用服务器"]
slug: "rails-page-cache-will-pagination"
draft: false
lastmod: "2008-07-28T23:34:05Z"
id: 220839
url: "https://jacky.iteye.com/blog/220839"
---

gregg的这两篇文章详细的描述了如何应用page cache和action cache ：
<http://www.railsenvy.com/2007/2/28/rails-caching-tutorial>
<http://www.railsenvy.com/2007/3/20/ruby-on-rails-caching-tutorial-part-2>

那Rails2.1结合Will-pagination是如何使用的呢？
routes.rb

```java

map.connect 'users/page/:page',
      :controller => 'users',
      :action => 'index',
      :requirements => { :page => /\d+/},
      :page => nil

```


Will-pagination的分页路径将由
```html
http://localhost:3000/users?page=1
```
,变为
```html
http://localhost:3000/users/page/1
```


再在Http服务器里配置直接读取静态文件，而不转发到CGI那性能会更上一步了。

请求http://localhost:3000/users 同 http://localhost:3000/users/page/1将会产生同样两个文件，但似乎影响不大。

如果rails采用文件cache，那再使用lighttpd+memcache,是不是比直接rails invoke memcache api强点呢？毕竟Ruby调用c，性能相比还是逊色。