Solved

Page expires when going back to previous page.

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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.

762 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

21 Experts available now in Live!

Get 1:1 Help Now