Solved

Page expires when going back to previous page.

Posted on 2003-11-27
5
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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.  …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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 dynamically set the form action using jQuery.

737 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