Solved

Page expires when going back to previous page.

Posted on 2003-11-27
5
327 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

774 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