Solved

Page expires when going back to previous page.

Posted on 2003-11-27
5
320 Views
Last Modified: 2013-12-12
Hello all,

I am in a catch-22 because my first problem was that my page was not updating and always display out dated infomation.  I correct my problem by placing

ob_start();
header("Cache-control: no-cache, must-revalidate");  
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date
header("Pragma: no-cache");

at the beginning of every page.  Now my problem now is that when I use the back button to return to the previous page, it always display an expired page and I am force to use the refresh button.  Is there any way to get around this?  I don't have this problem using ASP, but php has been giving me problems all the while.  It's too late for me to convert to ASP and I really love php.  I hope it is because I am doing something wrong.

Thanks

0
Comment
Question by:dtyson69
  • 3
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
ThG earned 125 total points
ID: 9837642
It doesn't matter whether you are using ASP or PHP. It's an HTTP trouble. You should check out ASP headers (with an http request/response tracking tool) and craft them using PHP.

Anyway I think your solution might be:
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
and drop all other headers.
Also try:
header("Cache-control: must-revalidate");  

should solve the "page expired" problem
0
 

Author Comment

by:dtyson69
ID: 9841298
Thanks ThG,

I've change all the header and it seems to work with the exception of a couple of pages.  I don't understand it because the only difference is that it is a little more database activity on those particular pages.  I've just run all out of ideas.  But for the most part, everything works great.
0
 
LVL 14

Expert Comment

by:ThG
ID: 9846163
make sure you are not using sessions on those pages. sessions completely revamp the cache settings, so they make those headear()s useless.
see session_cache_delimiter() function
0
 

Author Comment

by:dtyson69
ID: 9846221
Well, does that mean that I have to change my whole design logic?  All my code is session based.
0
 
LVL 14

Expert Comment

by:ThG
ID: 9846263
No, using sessions is ok, but just keep in mind that thing. also you can change those settings with session_cache_limiter to best fit your needs. that's all.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now