Hi! I am looking for a way of not caching page that make an error. For example, if a user hits /articles/10000000, I want to display a pretty error message with a rescue render :text=>"Blabla". However, I don''t want my "Blabla" to be cached! Is there a way of telling ruby "not to cache this page now"? Thank you! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 9/13/06, Nauhaie None <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi! > > I am looking for a way of not caching page that make an error. > > For example, if a user hits /articles/10000000, I want to display a > pretty error message with a > > rescue > render :text=>"Blabla". > > However, I don''t want my "Blabla" to be cached! Is there a way of > telling ruby "not to cache this page now"? > > Thank you! > > -- > Posted via http://www.ruby-forum.com/.When you cache a page, rails does not even get asked to execute anything if the file exists and the server will serve it as a static page. If you want to avoid this and have the caching dependent on some logic in you controller action, you need to use fragment caching. Action caching may work but I''m not too familiar with it. There is heaps of information in the docs under caching for the three options. Cheers --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
In fact, I think I just found the solution... What about adding an after_filter :cache_page_unless_error=>[cached actions], which page_cache if @do_not_cache.nil? Then, when I rescue an error, I add @do_not_cache=true, and it appears to work!! Nauhaie -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---