Firefox: connection determined in PHP script - php

I've set up an Apache Server as localhost in a openSUSE 13.1 64 bit system and I'm currently testing my PHP scripts.
In Konquerer 4.11.5 everything seems fine, but with Firefox 29.0.1 there is a strange phenomenon:
Every 10th time or so the connection fails. Firefox reports: "Connection determined".
The failed connection is listed neither in error_log nor in access_log.
The error must be quite "early". Because my PHP script output.php calls "itself" via
header("Location: output.php?changed_url");
almost immediately, but the Firefox error is BEFORE output.php is opened for the second time.
I have no idea what to do about this. It's a quite annoying issue.
All answers will be appreciated! Thanks in advance!

I guess you are missing
exit;
after the header() location change.
So you have an open script, firefox redirecting to the next (itself) and still having one open, ... I think firefox doesn't like this kind of loop ;)

Do you have any .htaccess file there? Have you tried using firefox from different OS or computer? I bet it's related to your installation of firefox :) (i ain't pro take it as guess)

Related

Entire PHP script being echo'd out instead of specific line

MCVE:
<?php
echo "testing!";
?>
Screenshot from accessing this script in Chrome:
Screenshot from running this script via the PHP command-line:
What's weird is that it hasn't always been this way. Everything was working perfectly yesterday, but ever since today, it's been doing this for whatever reason. Did I screw something up within the config of my Apache accidentally or something? Using XAMPP with PHP v7.3.8.
Wow, good catch KIKO Software! After checking the encoding of the file in Notepad++... I realized that it, for some reason, was set to "UCS-2 LE BOM". I changed it to "UTF-8" and now everything is working properly. Thank you!

PHP filemtime() not working - cache problem?

I am calling filemtime() from a PHP file executed by POST from a JavaScript/HTML app. It returns the same time stamp for a separate test HTML file every two seconds even when I edit the test file with a text editor and I can see its DTM change in the local file system.
If I reload the entire app (Ctrl+F5), the timestamp reported stays the same. At times (once after 4 hours) the time stamp changes, but I don't know what makes this happen.
The PHP part of my code looks like this:
clearstatcache(true,$FileArg);
$R=filemtime($FileArg);
if ($R===false)
echo "error: file not found";
else
echo $R;
This code is called by synchronous Ajax, given only its PHP filename, using setInterval every 2 seconds.
Windows 10 Home, Apache 2.4.33 running locally for HTTP access, PHP 7.0.30 .
ADDED:
The behavior is the same in Firefox, Chrome, Opera, and Edge.
The results are being cached: http://php.net/manual/en/function.filemtime.php
Note: The results of this function are cached. See clearstatcache() for more details.
It almost sounds like Windows is doing some write caching...
stat() on the other hand has an additional note:
Note:
Note that time resolution may differ from one file system to another.
Maybe worth checking stat output.
edit
Maybe it's a bug, or Windows not playing nice, but you could also do a shell_exec with the Windows command showing DTM.
News: it turns out to be an ordinary bug in my app. I copied my Ajax call and forgot to edit it to apply to the test file. So it applied to one of my app files instead and the DTM only got updated when I edited that app file (FTAdjust.js).
When I specify the correct test file, the DTM updates just fine each time I edit it in another process.
It can sometimes be hard to find one's own bug even when it stares one in the face! I kept looking everywhere else but where the mistake was.
Is there a way to delete a thread from Stack Overflow, since it is irrelevant to others?

PHP Reload Time

Hello I have a Problem with my PHP. Im coding in two ways:
I upload a File to my FTP Sever
Save it Local and run it with MAMP (OSX)
But in both ways i save/upload the new file but it takes about 2-5 Min until i can see the changes.
Example:
Old PHP:
<?php
echo "test";
?>
New PHP:
<?php
echo "test2";
?>
So i save the second file but until i see the second text it may taxes aboout 2-5 Minutes?
Can i change something in my PHP Info file or something else ? Or is there another way to code in PHP ?
This sounds like a caching problem. Try hitting Cmd+Shift+R* and see if the changes are instant then. If that's the problem, see this answer for how to disable the cache to prevent this problem.
Also, as loveNoHate points out in the comments, it is possible that this is a server- or ISP-side caching problem. Because you have the same problem running it locally on MAMP, however, it sounds like a browser issue.
* The Mac OS X shortcut. For future visitors: you would use Ctrl+F5 for Windows.
Since this is mac you might want to do
For Safari: Opt+Cmd+E to clear cache and Cmd+R to refresh
For Chrome: hold down Cmd and Shift key and then press R.

Safari PHP form submission -file upload hangs

I have an issue with safari 5+. When client selects the image file to upload through a simple HTML form the MAC version of Safari 5.1 (so far the only browser I found which is doing this) keeps hanging indefinitely.
I have my upload time and size in php.ini set correctly and it works in all other browsers (FF, Opera even IE!) so I do not suppose I have some rookie mistake in the HTML or PHP.
I have searched through many posts and found a bug report which is related to this issue (https://bugs.webkit.org/show_bug.cgi?id=5760). Also I found several Ajax workarounds but none of them has been the right fit. I am not using Ajax on this page and actually due to redirects I do not want to anyway.
Does anyone know the solution?
Also.... suggestions like adding <? header('Connection: close'); ?> to the file make things worse for Opera.
Edit: April 10, 2013
I still did not figure out why Safari hangs on some image uploads. I am making this edit in case someone has a similar problem. BTW when Safari is ran in the VirtualBox the upload fails every time unlike Firefox or IE which works fine. (perhaps a settings issue?)
I found this workaround which is very easy to implement and so far worked with every mainstream browser I could test. (Source: http://www.atwebresults.com/php_ajax_image_upload/ ) However the original question still stands. Thank you.
A workaround for lighttpd:
$HTTP["useragent"] =~ "Safari" {
$HTTP["useragent"] !~ "Chrome" {
server.max-keep-alive-requests = 0
}
}
Jamis Buck discovered it and I added the config lines.
The second rule avoids restricting keepalives to Chrome which also has the Safari substring.
Courtesy of https://bugs.webkit.org/show_bug.cgi?id=5760

Page onload time is very high

I am trying to investigate the cause of slowness on my website.
Here I attach firebug screenshot:
As you can see, all of content is loaded in just 2.92s, but javascript onload event is fired up AFTER 17.67s.
In case you want to see the website itself: http://maylashop.com .
I have tried to use YSlow, I get A grade and it doesn't help.
If anyone have fix or know what caused this, please kindly let me know.
why http://cf.addthis.com ? http://platform.twitter.com, plusone.google.com .... I dont see you use them any where ? if you are using , add them when they are desired
follow the guide lines Yslow , get some matrix and the check what is the bottleneck
You will be happy to follow these rules
This is not a JavaScript problem. Your PHP script is taking that long to execute (see screenshot). All the other resources that page is loading (JS, CSS, images, etc.) are taking less than a second to load. I'm 95% sure this is caused by zlib.output_compression. Try adding the following code to the top of your script to see if disabling it does anything useful:
ini_set('zlib.output_compression', 0);
If that fixes it, then you could consider not using zlib.out_compression or figure out what specific thing in your code is causing problems with it (usually output buffering).
Pretty sure this is not related to javascript. Just to request your main page took about 2 seconds. Ran this on a linux machine:
date ; lynx -source http://maylashop.com/ > /dev/null ; date
Fri Apr 13 22:38:19 CEST 2012
Fri Apr 13 22:38:21 CEST 2012
This is an independent confirmation that the host is either generating the index page too slowly, or there is a network transfer issue.
Doing the same thing with /index.php or /index.html or even a 404 page I created on the fly results with same ~2 second delay.
Edit: checked image download speed, and that one is <1 second. Close to 0.
Something in your PHP code might be creating the problem (inducing a delay.) One of those things could be delay in connecting to a MySQL server (or whatever you're using.) Is the database server on the same exact machine, or remote? Are you connecting to it on each call, or do you have a caching system in place?

Categories