Topic: caching everything but the flash[:notice]

I'm working on tuning my app to really go quick using things like caches_action and caches_page. In more than a few instances, I'd like to cache the entire page (it could be a static page) except for the few instances where an exception might occur.

In particular, I'm thinking of my login page. The XHTML will not change, but if there is an incorrect login, I need to display that message. Is there a way to cache the action or page, maintain the flash message and not use the fragment caching?

Thanks,
Bryce

Ruby on Rails application developer - www.brycemcdonnell.com

Re: caching everything but the flash[:notice]

You could AJAX to check for flash[:notice]... you'd have to do it on each request though, so it's a trade off. Another thing you could try is to set a cookie with a notice and check it with JavaScript and then remove it right after.

Basically, you need to perform a check with JS and deliver the notice to it in one way or another.

Re: caching everything but the flash[:notice]

http://blog.hasmanythrough.com/2007/8/8 … ched-pages

Re: caching everything but the flash[:notice]

cool thanks. It's nice to know I'm not the only one going through this.

Incidentally, I found another workaround simply by using the render :action => 'foo' method. I can cache actions without a problem and when an exception arises which would render a flash message, simply use render :action instead of a redirect_to :action.

Thanks again,
Bryce

Ruby on Rails application developer - www.brycemcdonnell.com