Forum Moderators: coopster
I think this will be the last time to seek after code that prevent cache and let the page get request from the server each time its just displayed on the screen!
I submit form and browser back button keep that the data there, but if it was fetched from the server then it will find that the session is deleted so all the text boxes will be deleted... but that never happen untill i refresh it myself..
I searched a lot and tried everything and this is what i am using now! and this problem exists in all forums but i c lot of sites that use this... for example phpMyAdmin... and i searched its code but i couldnt get how they did it yet!
I've this code in begining of the page.. but doesnt fetch new request from server... so please help me..
<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . date("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
Thanks in advance
[shiflett.org...]
This might help.
i understand your concerns and problems reagarding caching. http (the protcol used by browsers) contains some very simple rules:
a GET request can be cached. keep in mind that caching does not only mean the browser cache (private), it means proxy or webcaches, too (public).
a POST request can not be cached, that means, if you ensure that the request is done by POST (not GET which is the standard one), the request will never be cached.
with these simple rules in mind it is possible to understand why the browser is displaying a "Page Has Expired" Warning (the one coopster is pointing on).
for your specific problem with the form: just transport any data the user putted into the form with the request itself (i.e. within the so called POSTDATA) and php on the server can pre-fill the form.
browser back button then the page get fetched from the Server and not from the cache.. thats it!
so i suggest to choose the post method instead of the get method to let your forms and pages be requested again.
my problem is not with "Page Has Expired"
coopster:
To the best of my knowledge you cannot control that. It is a browser function.
FireFox will ask if you want to POST again whereas MSIE will not.
For the linked article: Well done but a very important point is left out: What about the user? Does he/she wants to know what's going on or not? If I see that message box I know the page is coming fresh from server. If I'm not confident with the default behaviour of my browser I should fire the Development Team a mail and request an option for that or a change with the default implementation. Maybe Bugzilla is full with such requests an the Developers itself will write their point of view down there.
But all this is about the article only and as cited smagdy just does not care about this warning anyway.
Ex. ive now a form and the user upload a picture and he gets directed to next page where the picture is displayed...
If he click the back button he MUST see the pic also displayed there and that wont happen unless he refresh the page once.. so if the page was fetched from the server he would c it but if from cache then he will just see the upload input box...
Anyways if someone want to see it then go to blocket.se its the biggest web site in sweden that let people buy/sell used stuff.. but maybe u wont get ur way here unless u know Swedish..
...........