# Handling Page updated Status

**URL:** <https://www.ruby-forum.com/t/handling-page-updated-status/85011>\
**Category:** Rails\
**Created:** [February 9, 2007, 8:41am UTC](https://www.ruby-forum.com/t/handling-page-updated-status/85011 "2007-02-09T08:41:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![syedarif](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@syedarif](https://www.ruby-forum.com/u/syedarif)\
**Post date:** [February 9, 2007, 8:41am UTC](https://www.ruby-forum.com/t/handling-page-updated-status/85011/1 "2007-02-09T08:41:08Z")

</div>

hi all,  
This is my first post in this forum. Found the site pretty  
useful.  
I have a link in a page, clicking on it takes to another page and  
immediately changes the status of a variable. Now if i press the browser  
back button the changes in the variable is not reflecting. The reason  
being it takes the information form the browser cache. I expect the  
latest updated status of the variable. Need help.

---

<div class="post-metadata">

**Author:** ![syedarif](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@syedarif](https://www.ruby-forum.com/u/syedarif)\
**Post date:** [February 9, 2007, 5:54pm UTC](https://www.ruby-forum.com/t/handling-page-updated-status/85011/2 "2007-02-09T17:54:25Z")

</div>

Syed Arif wrote:

> hi all,  
> This is my first post in this forum. Found the site pretty  
> useful.  
> I have a link in a page, clicking on it takes to another page and  
> immediately changes the status of a variable. Now if i press the browser  
> back button the changes in the variable is not reflecting. The reason  
> being it takes the information form the browser cache. I expect the  
> latest updated status of the variable. Need help.

By default rails tells the browser not to cache your apps pages.  
However, the back button usually ignores this. Firefox even keeps your  
form fields and changes made by javascript in the back-button cache and  
it’s touted as a feature.

I’m not sure there is a way around this. Back button’s can be quite  
problematic for web apps.

---

<div class="post-metadata">

**Author:** ![syedarif](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@syedarif](https://www.ruby-forum.com/u/syedarif)\
**Post date:** [February 10, 2007, 6:50pm UTC](https://www.ruby-forum.com/t/handling-page-updated-status/85011/3 "2007-02-10T18:50:36Z")

</div>

Syed Arif wrote:

> ```
> I have a link in a page, clicking on it takes to another page and
> 
> ```
> 
> immediately changes the status of a variable. Now if i press the browser  
> back button the changes in the variable is not reflecting. The reason  
> being it takes the information form the browser cache. I expect the  
> latest updated status of the variable. Need help.

Try adding “expires\_now” to the action that generates the page  
containing the variable:

[Peak Obsession](http://api.rubyonrails.com/classes/ActionController/Base.html#M000273)

–  
We develop, watch us RoR, in numbers too big to ignore.

---

<div class="post-metadata">

**Author:** ![syedarif](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@syedarif](https://www.ruby-forum.com/u/syedarif)\
**Post date:** [February 13, 2007, 1:10pm UTC](https://www.ruby-forum.com/t/handling-page-updated-status/85011/4 "2007-02-13T13:10:44Z")

</div>

Mark Reginald J. wrote:

> Syed Arif wrote:
> 
> > ```
> > I have a link in a page, clicking on it takes to another page and
> > 
> > ```
> > 
> > immediately changes the status of a variable. Now if i press the browser  
> > back button the changes in the variable is not reflecting. The reason  
> > being it takes the information form the browser cache. I expect the  
> > latest updated status of the variable. Need help.
> 
> Try adding “expires\_now” to the action that generates the page  
> containing the variable:
> 
> [Peak Obsession](http://api.rubyonrails.com/classes/ActionController/Base.html#M000273)
> 
> –  
> We develop, watch us RoR, in numbers too big to ignore.

expires\_now did not work. i need to clear the cache of the browser, if  
action\_expires is used in the response @headers={“cookie”=\>[],  
“Cache-Control”=\>“no-cache”} is set but still it takes the cache  
information…  
Have no clue what to do… or i am thinking of removing the back button  
from my application.

---

<div class="post-metadata">

**Author:** ![syedarif](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@syedarif](https://www.ruby-forum.com/u/syedarif)\
**Post date:** [February 25, 2007, 8:52am UTC](https://www.ruby-forum.com/t/handling-page-updated-status/85011/5 "2007-02-25T08:52:32Z")

</div>

Syed Arif wrote:

> Mark Reginald J. wrote:
> 
> > Syed Arif wrote:
> > 
> > > ```
> > > I have a link in a page, clicking on it takes to another page and
> > > 
> > > ```
> > > 
> > > immediately changes the status of a variable. Now if i press the browser  
> > > back button the changes in the variable is not reflecting. The reason  
> > > being it takes the information form the browser cache. I expect the  
> > > latest updated status of the variable. Need help.
> > 
> > Try adding “expires\_now” to the action that generates the page  
> > containing the variable:
> > 
> > [Peak Obsession](http://api.rubyonrails.com/classes/ActionController/Base.html#M000273)
> > 
> > –  
> > We develop, watch us RoR, in numbers too big to ignore.
> 
> expires\_now did not work. i need to clear the cache of the browser, if  
> action\_expires is used in the response @headers={“cookie”=\>[],  
> “Cache-Control”=\>“no-cache”} is set but still it takes the cache  
> information…  
> Have no clue what to do… or i am thinking of removing the back button  
> from my application.

hi, i got the solution, it works in firefox, since iam using apache  
server  
i can set my headers not to cache the pages “no-store”. but in ie it  
does not work… any idea…???

---

<div class="post-metadata">

**Author:** ![syedarif](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@syedarif](https://www.ruby-forum.com/u/syedarif)\
**Post date:** [February 26, 2007, 3:24pm UTC](https://www.ruby-forum.com/t/handling-page-updated-status/85011/6 "2007-02-26T15:24:41Z")

</div>

syed arif wrote:

> Syed Arif wrote:
> 
> > Mark Reginald J. wrote:
> > 
> > > Syed Arif wrote:
> > > 
> > > > ```
> > > > I have a link in a page, clicking on it takes to another page and
> > > > 
> > > > ```
> > > > 
> > > > immediately changes the status of a variable. Now if i press the browser  
> > > > back button the changes in the variable is not reflecting. The reason  
> > > > being it takes the information form the browser cache. I expect the  
> > > > latest updated status of the variable. Need help.
> > > 
> > > Try adding “expires\_now” to the action that generates the page  
> > > containing the variable:
> > > 
> > > [Peak Obsession](http://api.rubyonrails.com/classes/ActionController/Base.html#M000273)
> > > 
> > > –  
> > > We develop, watch us RoR, in numbers too big to ignore.
> > 
> > expires\_now did not work. i need to clear the cache of the browser, if  
> > action\_expires is used in the response @headers={“cookie”=\>[],  
> > “Cache-Control”=\>“no-cache”} is set but still it takes the cache  
> > information…  
> > Have no clue what to do… or i am thinking of removing the back button  
> > from my application.
> 
> hi, i got the solution, it works in firefox, since iam using apache  
> server  
> i can set my headers not to cache the pages “no-store”. but in ie it  
> does not work… any idea…???

hi all,  
Finally found the way to handle back button problem in browsers if  
your web server in apache 1.3 or greater.  
In IE , iam using apache2.2.3 and it sends http1.1 response. Rails by  
default sets the the Cache-Control to “no-cache” so it should always  
fetch the fresh page.(make sure that u bypass proxy, if used.)

In FF, u need to set “no-store” in Cache-Control so u will get the fresh  
page  
(do not worry about proxy here)

1. The best way is to set these http response headers in .htaccess files  
under public folder in your rails application.  
Header set Cache-Control “no-store, no-cache”.

2. The other way is to set in every response you send from the code  
using the interfaces available to set the http headers in rails.

I will suggest the first one.

HTTP 1.1 is intelligent that HTTP1.0 in caching mechanism.

Thanks.
