|Opera not reading php|
| 1:02 am on Jun 17, 2007 (gmt 0)|
$this = rand(1,8);
$includefile = "file" . $this . ".txt";
Browsers are supposed to load a page when it first opens them and refreshes them when it comes back to one page from another. However opera isn't refreshing php. Anyone know why? Works fine in other browsers but when you go a page with this script in it in opera, opera only shows the same items over again and doesen't change to another item.
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.
| 1:16 am on Jun 17, 2007 (gmt 0)|
No browser ever reads PHP - it is parsed on the server and the resulting generated HTML is sent to the browser.
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?
| 2:18 am on Jun 17, 2007 (gmt 0)|
If this happens on Back, then Opera will just use the page that is cached in memory in most cases. Opera will reload the page in some cases, which are explained here: [opera.com...]
| 3:16 am on Jun 17, 2007 (gmt 0)|
Thanks, this happens whenever you open opera to the same page again. Whether coming to it from another page, reopening opera to the same address, or using the back button, any viewing of these at all done with opera.
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.
| 4:19 am on Jun 17, 2007 (gmt 0)|
Adding Cache-Control headers to your site should improve it.
| 4:25 am on Jun 17, 2007 (gmt 0)|
As stated above, the server processes the PHP code, and sends the resulting HTML to the requesting client (browser). Opera is caching that result, and when it sees another request for the same URL after only a very short period of time, it renders (prints on the screen) the version it has already cached. Which is what it should do to save time and server and network bandwidth, unless you tell it differently.
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.
| 3:35 am on Jun 22, 2007 (gmt 0)|
Thank you that was very helpful. How do I try doing the back=done? Its seems like that would be the easiest way to start out. Someone please let me know, thank you very much.
| 5:46 pm on Jul 1, 2007 (gmt 0)|
I'm still having trouble with Opera. Could some others please test my code in opera and see if you have the same problem? I am hoping there is just something wrong with my computer and the code works fine. I downloaded brand new versions of opera already but maybe there is something not being removed properly.
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