# Caches\_page

**URL:** <https://www.ruby-forum.com/t/caches-page/110057>\
**Category:** Ruby\
**Created:** [July 22, 2007, 7:01am UTC](https://www.ruby-forum.com/t/caches-page/110057 "2007-07-22T07:01:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/82dd89/32.png) [@kris](https://www.ruby-forum.com/u/kris)\
**Post date:** [July 22, 2007, 7:01am UTC](https://www.ruby-forum.com/t/caches-page/110057/1 "2007-07-22T07:01:27Z")

</div>

I’m looking for something that has similar functionality to the  
caches\_page directive provided by rails but that caches a seperate based  
on the params that are passed into the request. For example if I have a  
request [http://www.foo.com/mycontroller?id=1](http://www.foo.com/mycontroller?id=1) and a request  
[http://www.foo.com/mycontroller?id=2](http://www.foo.com/mycontroller?id=2) I’d like a seperate cache for each  
of those requests. Based on my experimentation with caches\_page it  
looks like all I get by default is a cache for the first of those 2  
requests that is called.

Ideas? Is there a simple way for caches\_page to take into account the  
params that are passed in?

---

<div class="post-metadata">

**Author:** ![kris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/82dd89/32.png) [@kris](https://www.ruby-forum.com/u/kris)\
**Post date:** [July 23, 2007, 2:38am UTC](https://www.ruby-forum.com/t/caches-page/110057/2 "2007-07-23T02:38:41Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Kris Kohlstedt wrote:

> params that are passed in?  
> Instead of calling [http://www.foo.com/mycontroller?id=2](http://www.foo.com/mycontroller?id=2), call  
> [http://www.foo.com/mycontroller/index/2](http://www.foo.com/mycontroller/index/2). Rails will place ‘2’ into  
> params[:id],  
> and it will cache the page into public/mycontroller/index/2.html

That is assuming you haven’t deleted this line from the end of your  
config/routes.rb:

```
map.connect ':controller/:action/:id'

```

* * *

Travis W.

“Programming in Java is like dealing with your mom –  
it’s kind, forgiving, and gently chastising.  
Programming in C++ is like dealing with a disgruntled  
girlfriend – it’s cold, unforgiving, and doesn’t tell  
you what you’ve done wrong.”  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.7 (MingW32)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org](http://enigmail.mozdev.org)

iD8DBQFGo/hOWvapaOIz2YYRAlAHAJsEmZ0Ct3erw/QirlpwoC0lHc6mEwCfcYjG  
CdY1L3+XMlVVcHYm/K4F1B8=  
=ZKGP  
-----END PGP SIGNATURE-----
