Forum: Ruby on Rails rails won't cache my action

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
73606b1d1042de19056f3d59492b652f?d=identicon&s=25 Charlie Bowman (beachguy82)
on 2006-04-08 22:39
I've decided to dive into page caching for my rails app.  I'm doing my
testing with webbrick and it refuses to display the cached page for a
particular action.  I've modified my paginator helper to put the page
parameter in the url so that the paginated page can be used with
caching.  This works perfectly when the page parameter is in the url (ie
browse/2006/2 or browse/2006/1).  Both of those url put the cached file
in public/browse/2006/1.html and 2.html.  They work fine and webbrick
displays the cached version.  If I leave off the trailing 1 or 2 then
the cached file is created in public/browse/2006.html.  The file is
getting created with each request instead of serving the cached version.
What can I do to fix this problem.  I'm running rails 1.1  Here is my
routes.rb.  I think it might have something to do with the problem.
  map.connect 'pragmatic/browse/:id/:page',
    :controller => 'pragmatic',
    :action => 'browse_date',
    :requirements => { :page => /\d+/},
    :page => nil,
    :id => /\d\d\d\d/
D90ef6808433e63203e15a5c2dadb0bb?d=identicon&s=25 Ben Reubenstein (Guest)
on 2006-04-08 22:47
(Received via mailing list)
Are you running in the development environment?  Caching only works when
your environment is production.

~ Ben
D90ef6808433e63203e15a5c2dadb0bb?d=identicon&s=25 Ben Reubenstein (Guest)
on 2006-04-08 22:47
(Received via mailing list)
whoops... didn't read all the way through... how are you setting up the
caching in your controller?
73606b1d1042de19056f3d59492b652f?d=identicon&s=25 Charlie Bowman (beachguy82)
on 2006-04-08 22:49
Ben Reubenstein wrote:
> whoops... didn't read all the way through... how are you setting up the
> caching in your controller?

Here is my controler caching line
caches_page :index, :view, :browse, :browse_date, :rss
73606b1d1042de19056f3d59492b652f?d=identicon&s=25 Charlie Bowman (beachguy82)
on 2006-04-09 00:29
charlie bowman wrote:
> Ben Reubenstein wrote:
>> whoops... didn't read all the way through... how are you setting up the
>> caching in your controller?
>
> Here is my controler caching line
> caches_page :index, :view, :browse, :browse_date, :rss

It turns out the problem is in the routes.rb
I'm not sure why but I had to make the following change so that there
the action portion of the route wasn't hard coded.  Maybe someone knows
why this works but the previous example of mine didn't.

  map.connect 'pragmatic/:action/:id/:page',
    :controller => 'pragmatic',
    :requirements => { :page => /\d+/},
    :page => nil,
    :id => /\d\d\d\d/
This topic is locked and can not be replied to.