Welcome to WebmasterWorld Guest from 188.8.131.52
Forum Moderators: open
The above just loads a different file named .txt randomly. So if you load a file named file01.txt up to 8 and put some text in them, it will pick a different .txt file each time on page load. That is what it is supposed to do but not working in Opera. Anyone know why? Thank you very much.
What you have in this instance is that Opera is caching (keeping in memory) the initially-generated page, not returning to the server with each visit.
Are you saying this is happening when the user uses the Back button on the browser, or when they return via a link from another page? Are you sending any cache-control headers?
But aside from not being able to understand why Opera would choose this just for a little extra speed, just adjusting my opera settings won't work because any visitors that visit my pages will have the same problem.
What can I do to get php working on page load in opera so visitors will see the correct php output? Please let me know, thank you very much.
The way you tell it not to do this is to either use a different URL (for example a different page name, or the same page name with a new query parameter appended such as "back=done") or by sending a cache-control header from the server when the original page is served, telling the browser --literally-- "Don't cache this page." You can do this at the server configuration level, or in PHP, or in a number of different ways.
One challenge we face as Webmasters is to make our sites work with a wide array of browsers, and their different ways of interpreting the HTTP (and other) specifications. One can either concentrate on saying that this or that browser is "wrong," or save a lot of time and frustration by going about the business of getting one's site to work with it anyway. In this case, the use of a "Cache-control: no-cache, must-revalidate" header will likely solve your problem.
If you want to see the headers that your server is sending, I recommend the "Live HTTP Headers" extension for Firefox and Mozilla-based browsers. Nothing fancy, but simply a great free tool.
I tried putting the php script above any page headers, didn't work. I tried putting this at the top of the php script as well,
didn't work. I also tried each of these just above and below the title tag of the page
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Expires" CONTENT="Tue, 15 July 2007 14:25:27 GMT">
Here is the script.
$maximum = 2;
$a = (isset($_COOKIE['e']) && intval($_COOKIE['e']) < $maximum)? intval($_COOKIE['e'])+1 : 1;
setcookie("e", $a, time()+60*60*24*30);
$include_file = "file" . $a . ".txt";
All you have to do is put a bit of different text in 2 .txt files.
Upload them to your root and name them file1.txt and file2.txt.
Then put the script in a .php page and upload that page. Open the script page and you should see the text in your two other files on each next page load. When you open each browser again from scratch it swithes between the two text files. But with opera, when you open it fresh again and go back to the script page, it is the .txt file that was there before, not the next new one.
Please let me know if your opera shows the next .txt file each time with a brand new open of opera to the script page. If it does, please let me know if you can think of changing any history or cache settings previously. That will tell me if I have a faulty computer, opera, or not.
Thanks everyone who can help me with this. Simone