Can pagination work with caching

I am currently caching a page that indexes blog entries. Paginate was
used to break the entries up. Now when you click on next at the bottom
of the page it is only reloading the first page. Im hoping, against
odds, that someone here knows of a way to make paginate and cache play
together.

I am currently caching a page that indexes blog entries. Paginate was
used to break the entries up. Now when you click on next at the bottom
of the page it is only reloading the first page. Im hoping, against
odds, that someone here knows of a way to make paginate and cache play
together.

You can page cache with paginate if you put your page numbers in your
path instead of the query string. Try this route:

map.connect ‘blog/:page’, :controller => ‘blog’, :action => ‘index’,
:page => nil

This will give you URLs like “/blog/2” instead of “/blog?page=2”,
meaning that they’ll be cached as “public/blog/2.html”.

If you must keep your query string, have a look at this:

http://scottstuff.net/blog/articles/2005/10/04/rails-caches_action_with_params


Michael D.
http://www.mdaines.com

Fantastic, you sir are a new friend of mine. I obviously need to study
up on routes and their configuration.

Thanks,
Dorian

Michael D. wrote:

I am currently caching a page that indexes blog entries. Paginate was
used to break the entries up. Now when you click on next at the bottom
of the page it is only reloading the first page. Im hoping, against
odds, that someone here knows of a way to make paginate and cache play
together.

You can page cache with paginate if you put your page numbers in your
path instead of the query string. Try this route:

map.connect ‘blog/:page’, :controller => ‘blog’, :action => ‘index’,
:page => nil

This will give you URLs like “/blog/2” instead of “/blog?page=2”,
meaning that they’ll be cached as “public/blog/2.html”.

If you must keep your query string, have a look at this:

http://scottstuff.net/blog/articles/2005/10/04/rails-caches_action_with_params


Michael D.
http://www.mdaines.com