How not to cache a page with a rescued error

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!

On 9/13/06, Nauhaie N. [email protected] wrote:

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

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