# How to avoid past pages to be displayed

**URL:** <https://www.ruby-forum.com/t/how-to-avoid-past-pages-to-be-displayed/117851>\
**Category:** Rails\
**Created:** [October 21, 2007, 3:41pm UTC](https://www.ruby-forum.com/t/how-to-avoid-past-pages-to-be-displayed/117851 "2007-10-21T15:41:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@luma](https://www.ruby-forum.com/u/luma)\
**Post date:** [October 21, 2007, 3:41pm UTC](https://www.ruby-forum.com/t/how-to-avoid-past-pages-to-be-displayed/117851/1 "2007-10-21T15:41:38Z")

</div>

I’ve got the following problem with firefox:

When I click the back button after logging out, I can see all the  
pages of the browser history where I was logged in. These pages are  
not reloaded, so I assume the before\_filter is not called. How do  
other pages like [groups.google.com](http://groups.google.com) avoid the browser history being  
displayed again?

# before\_filter for all methods that require the user to be logged

in:  
def user\_test\_logged  
@user = User.find\_by\_id(session[:user\_id])  
if @user.nil?  
redirect\_to(:controller =\> “login” , :action =\> “login” ) and  
return false  
end  
end

def login  
reset\_session  
if request.post?  
user = User.authenticate(params[:name], params[:password])  
if user  
session[:user\_id] = user.id  
redirect\_to :action =\> ‘index’ and return false  
end  
end  
render :layout =\> false  
end

def logout  
redirect\_to :action =\> ‘login’  
end

thanks  
Luma

---

<div class="post-metadata">

**Author:** ![luma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d6d6ee/32.png) [@luma](https://www.ruby-forum.com/u/luma)\
**Post date:** [October 21, 2007, 6:43pm UTC](https://www.ruby-forum.com/t/how-to-avoid-past-pages-to-be-displayed/117851/2 "2007-10-21T18:43:49Z")

</div>

You are probably in development mode and viewing the browsers cache. In  
production mode, this shouldn’t happen, although there really is no way  
to completely prevent it. Production mode sends the no-cache header, but  
it’s up to the particular browser to decide whether to abide by that or  
not.

-Bill

Luma wrote:

> in:  
> if request.post?  
> redirect\_to :action =\> ‘login’  
> end
> 
> thanks  
> Luma
> 
> >

–

Sincerely,

William P.
