Page 1 of 1
HELP nocache but still allow back button
Posted: Fri May 03, 2002 5:50 pm
by mike608
Having trouble with this -- can't seem to find a difinitive answer.
I have a page that displays a new image from a post. But when I return to this page by clicking the back button, the page has expired.
Does anyone know how to disable cache BUT STILL still allow the user to click the back button (in the browser) and have a dynamic page displayed (ie data is drawn from the database).
Two problems: 1) If I disable the cache I can obtain the non-cached page by clicking a link that returns to this page. 2)If I enable cache, I get a cached page but I can click the back button. Catch 22 situation. Any way around this???
*note:
- I have tried header, session_cache_limiter, etc, etc.
-I do NOT want to use get instead of post
Thanks so much.
Mike.
Posted: Fri May 03, 2002 7:14 pm
by pozytron
There's not many ways to do this, because http is a stateless protocol. Don't bother messing around with headers, because it won't work that way. I can think of a few things:
* You can use cookies, and store the variables in cookies. This is not the preferred method because many people think that cookies are evil and turn them off.
* Really, GET would be the easiest way. I know you specifically stated you don't want to use it, but I don't see why. Is it because you don't want a super-long URL?
* The final, and most complicated method would be to set up a database that automatically registers a userid (stored in the url, i.e. page.php?uid=6 or with cookies). The database would need some sort of timeout feature where it automatically deletes inactive users. You'd then store your variables in the database. If you really don't want anything in the URL, you could be even more complicated and get the user's IP, store that, and associate some variables with it.
Other than the above obvious and cheesy ideas, you have me baffled.
even GET method would not work perfectly right?
Posted: Fri May 03, 2002 7:29 pm
by mike608
Even if I use a get method, when I hit the back button in the browser, I will get stale data, correct?
Thank you very much for your time.
Mike.
Posted: Fri May 03, 2002 9:16 pm
by pozytron
It depends on whether the user has their browser set to cache pages or not, as you said. If their browser does not cache pages, it will refresh with dynamic content when you use GET. If their browser always uses pages from a cache, there's nothing you can do (that I know of).
Cheers,
Robin Hamilton-Pennell
Posted: Mon Oct 14, 2002 10:09 am
by ericling
So what is the final verdict? I am having the same problem... What solution have you come up with?
I've tested this for u
Posted: Mon Oct 14, 2002 4:27 pm
by GroovyinAz
Code: Select all
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
I loaded a page that contains dynamic elements
I navigated forward
changed the database
and clicked back
The page displayed the new data without a refresh
Does this answer you question?