Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Page expires when going back to previous page.

Posted on 2003-11-27
5
Medium Priority
?
359 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 500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
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 …

722 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