Forum Moderators: coopster

Message Too Old, No Replies

IE6 Cache problem

i tried everything but nothing work....

         

smagdy

8:43 am on Apr 17, 2006 (gmt 0)

10+ Year Member



Hello,

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

coopster

1:06 pm on Apr 20, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Chris Shiflett has written up a How to Avoid "Page Has Expired" Warnings article:

[shiflett.org...]

This might help.

hakre

6:07 pm on Apr 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi smadgy,

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.

smagdy

8:32 pm on Apr 20, 2006 (gmt 0)

10+ Year Member



Hi, thanks for your replies, but my problem is not with "Page Has Expired"...

Simply all i need is when i click the browser back button then the page get fetched from the Server and not from the cache.. thats it!

coopster

4:59 am on Apr 21, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



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. Read the link provided again please as it is explained there.

hakre

6:46 am on Apr 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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"

even better! this message will come up while using post and the back button.

coopster:

To the best of my knowledge you cannot control that. It is a browser function.

True, it's the implementation.

FireFox will ask if you want to POST again whereas MSIE will not.

Partly false, because both will ask, that's the standard implementation - as any other browser will ask, too.

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.

smagdy

8:29 am on Apr 21, 2006 (gmt 0)

10+ Year Member



Well maybe i forgot to mention that i am using the POST Method in all my forms and never using the GET and i get the warning page... but i didnt think of removing it so far... all i want is the page to be fetch from the server again.. and i said i saw it in other sites..

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..
...........