To add cache I need to have url like news/page/2, urls like
news/?page=2 can’t be cached page by rails.
So any idea to solve this problem ?
The answer was “use fragment caching”
Controller
def index
unless read_fragment({:page => params[:page] || 1}) # Add the
page param to the cache naming @news = News.paginate :all, :page => params[:page]
end
end
View
<% cache ({:page => params[:page] || 1}) do %>
… All of the html to display the posts …
<% end %>
Nicolas C.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.