# Caching pages

**URL:** <https://www.ruby-forum.com/t/caching-pages/72778>\
**Category:** Rails\
**Created:** [October 18, 2006, 10:01pm UTC](https://www.ruby-forum.com/t/caching-pages/72778 "2006-10-18T22:01:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [October 18, 2006, 10:01pm UTC](https://www.ruby-forum.com/t/caching-pages/72778/1 "2006-10-18T22:01:44Z")

</div>

Hey,

I want to cache pages…  
I have this function show, and on top of my page I have the cache stuff.  
But it doesnt seem to work. Cuz I saw still queries in the development  
log file. Can anyone help me?  
I have tried caches\_page and caches\_action

And what about parameters like /show/1, /show/2, /show/3 =\>\> need to be  
different caches. Does anyone has any good full example?

class Frontend::ProductsController \< FrontEndController

caches\_page :show  
#caches\_action :show

def show  
@product = Product.find(:first, :conditions =\> [‘id = ?’, params[:id]])  
if @product == nil  
redirect\_to :action =\> ‘list’  
end  
end

end

Thx  
N.

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [October 18, 2006, 10:33pm UTC](https://www.ruby-forum.com/t/caching-pages/72778/2 "2006-10-18T22:33:20Z")

</div>

> Hey,
> 
> I want to cache pages…  
> I have this function show, and on top of my page I have the cache stuff.  
> But it doesnt seem to work. Cuz I saw still queries in the development  
> log file. Can anyone help me?

Caching isn’t enabled in development mode…

Set config.action\_controller.perform\_caching to true in  
config/environments/development.rb if you want to see how it works.

Or switch your environment to production…

-philip

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [October 19, 2006, 7:49pm UTC](https://www.ruby-forum.com/t/caching-pages/72778/3 "2006-10-19T19:49:44Z")

</div>

> Caching is by default turned off in development environment,  
> In your config/environments/production.rb file it sets some  
> caching settings to true, meaning it works only in production mode
> 
> Hope this helps!  
> Gustav  
> removed\_email\_address@domain.invalid

That works 😉

Thx  
N.

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [October 18, 2006, 10:35pm UTC](https://www.ruby-forum.com/t/caching-pages/72778/4 "2006-10-18T22:35:28Z")

</div>

Brutyn N. wrote:

> end
> 
> end
> 
> Thx  
> N.

Caching is by default turned off in development environment,  
In your config/environments/production.rb file it sets some  
caching settings to true, meaning it works only in production mode

Hope this helps!  
Gustav  
removed\_email\_address@domain.invalid

–  
about me:  
My greatest achievement was when all the other  
kids just learnt to count from 1 to 10,  
i was counting (0…9)

- gustav.paul
