Appologies for unclear title. I don't really understand the problem I'm facing.
My system: PHP 5.2.1, Win2K, Apache 2, MySQL 5 (local - problem is same on my live site running php 4.3.9, Linux, Apache 2). Various browsers.
No errors are reported (set to ALL and STRICT) with my problem.
To describe the problem a little more:
The symptoms - very slow page load. I can see the page reloading simply by observing the 'progress' bar in any browser. It will get to about 90% and then drop to 0, then get to about 90% etc. It is clearly loading the page more than once (well apparently). Otherwise, the scripts run with no problems.
The problem (I think). In an attempt to debug this problem, I've placed a function at the very very top of my first script which sends the REQUEST_URI reference and a timestamp to a text file. Inside some of the scripts in the page, I've placed similar functions to record some variables and arrays to the same text file. I've placed a third function at the very end of the last script on my page (ie the footer).
When I load a single page, the log file I created, shows a little more what is happening. The REQUEST_URI reference first says the page that I wanted (eg /home). Then i get something like /mycss/default.css as the file which is loaded. The odd thing is that the CSS files are all loaded inside the header which is included after the first script is loaded.
Another oddity is that I include about 3 or 4 standard CSS files in each page and this problem never occurs with them. I have a simple script which changes the CSS files included depending on user preference and these extra files are the only ones with the problem. Incidentally, it's not just CSS but also image and JS files.
I also checked the problem by having a session variable increment each time the page was loaded. For one load on one page, I got 27 counts!!! It seems that the script passed over the $_SESSION['page_count']++ 27 times! (it isn't in a loop by the way).
I actually managed to reduce that count by using absolute path references on some images. But I don't understand why that had an impact.
So the crux of my problem (appologies for long explanation!) - I can see the impact and I've tried very hard to determine the cause. I think I have the cause but I don't know the solution.
As you can see I'm getting very stuck and the performance hit is pretty huge. I'd be very very grateful for any help! Thanks in advance.
5 2190 pbmods 5,821
Recognized Expert Expert
Heya, henryrhenryr.
The problem (I think). In an attempt to debug this problem, I've placed a function at the very very top of my first script which sends the REQUEST_URI reference and a timestamp to a text file. Inside some of the scripts in the page, I've placed similar functions to record some variables and arrays to the same text file. I've placed a third function at the very end of the last script on my page (ie the footer).
Let's have a look at that function.
Hi! Thanks for replying so quickly! Here are the functions.
[PHP]
function debug($line,$fi le,$var=NULL,$l og=TRUE) {
$r=NULL;
if ($log) { $hr= NULL; } else { $hr= '<hr />'; }
$r .= '
<div class="debug">' .$hr.'Line: <b>'.$line.'</b> in File: '.$file.'<br />The given <b>$var</b>('.gettype($v ar).') is <br />';
if (is_array($var) && !empty($var)) {
$r .= display_array($ var);
}
elseif (is_object($var )) {
$r .= var_export($var ,TRUE);
}
elseif (is_string($var )) {
$r .= '('.strlen($var ).') '.$var;
}
elseif (is_resource($v ar)) {
$r .= var_export($var ,TRUE);
}
else {
$r .= var_export($var ,TRUE);
}
$r .= $hr.'</div>';
if ($log) {
$debug_log= './debug.html';
$f=fopen($debug _log,'a');
fwrite($f,$r);
}
else {
echo $r;
}
}
function debug_start() {
define('DEBUG_S TART',microtime ());
$r = '<div class="start">D ebugging Started of page '.$_SERVER['REQUEST_URI'].' at '.date("d m Y Gis").'</div>';
$debug_log= './debug.html';
$f=fopen($debug _log,'a');
fwrite($f,$r);
}
function debug_end() {
$now=microtime( );
$page_load_time =$now-DEBUG_START;
$r = '<div class="end">Deb ugging Ended of page '.$_SERVER['REQUEST_URI'].' at '.date("d m Y Gis").', taking '.$page_load_ti me.' seconds</div>';
$debug_log= './debug.html';
$f=fopen($debug _log,'a');
fwrite($f,$r);
}
[/PHP]
I think they aren't causing any problems with the pages themselves. I just use it to record some variables if I'm trying to find a logical error.
I have been continuing to investigate. I have worked out a bit more of the problem. The page that is being loaded isn't the css/js/jpeg file, it's the 404 error page that I made and directed to in my .htaccess.
The links to the css files in particular were a bit dodgy and then the server is returning a page not found error which returns my 404 page. That page is a normal page with menu, images, lots of includes etc. This will certainly explain the length of time to load.
The remaining problem is that I can't always be certain that a link (eg image, css, js file) will be valid (although obviously I'll try). But I don't want a mistake in the link to slow the loading of a page because it's loading the 404 error message in the background.
Is there a way to prevent this 404 error from loading but retain the nice looking page for genuinely not found pages.
Thanks again!
Update:
I think my problem revolves around HTTP headers. I have got the Live Headers extension for firefox and I can see that my .css need to be in one file to reduce requests and I need to use some headers to force caching of particular small gifs which seem to be downloaded seperately!
pbmods 5,821
Recognized Expert Expert
Heya, henryrhenryr.
Couple of things I would check: - Do you have a custom 404 error page configured? Double-check your httpd.conf file and search for ErrorDocument.
- Check your webserver's error_log file (on a *n?x system, it's probably located at /var/log/httpd/error_log). See what pages the browser was trying to access.
- Check the HTML of the page in the browser. Look for links to nonexistent files.
Thanks for reply...sorry it's been a few days!
Do you have a custom 404 error page configured? Double-check your httpd.conf file and search for ErrorDocument.
----> Yes. I was using a custom 404 page. I have removed it and the load speed dramatically increased. But now I have no 404 page - is there anyway to get around this?
Thanks!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: DeadCert |
last post by:
Hi, How can I store all my scripts on a separate page and then call
them from the html page that I want to use them on? the <head> section
is getting too cluttered and I would like to store all in one place.
Anyone know how? Cheers
|
by: M K |
last post by:
Our production software (which works with images) has an
internal webserver operating on port 80. This resides in
within our firewall. It processes scripts (kpl scripts)
that generate an image. So on our intranet if we have an
image tag with a src
of '//internalServer/render/script.kpl?Value1=2341' the
image appears on the page. That is...
|
by: Richard |
last post by:
Hey there,
I have a textbox and a listbox. When a user types a number in the textbox, I
want to get
all the records from a MS Access DB but without reloading the page. I now
have something manual
and a user first must press a button to get the listbox filled with records
but I want to have it done
automaticly without pressing a sumbit...
|
by: Yogi_Bear_79 |
last post by:
I have a script that parses window.location.hash to figure out which xml
file to load. The xml files populate a page on a framed site. The code works
correctly to a point.
If I have a seperate html page to support each xml it works. I would like to
eliminate the individual html pages becuase only one should be needed.
When I use one page...
|
by: Gummy |
last post by:
Hello,
I created a user control that has a ListBox and a RadioButtonList (and other
stuff). The idea is that I put the user control on the ASPX page multiple
times and each user control will load with different data (locations,
departments, etc.).
| |
by: paul |
last post by:
Hi All,
We have a small dilemma. We have the following page:
http://giggsey.com/m00Cow.php (don't ask about the content) that we
want to turn into an interactive application for some new intake
students at our school. However - we want to have multiple client PCs
running a web interface that will allow them to type in their name / a...
|
by: Peter |
last post by:
I have a problem with a page show_image.asp that returns a jpg image under
Windows XP Pro SP2. The page sets content type as:
Response.ContentType = "image/jpg"
While this works perfectly fine on most machines, on some machines I
experience this problem:
When loading the page a window pops up that asks if I want to open the
document...
|
by: =?Utf-8?B?V2FubmFiZQ==?= |
last post by:
We have a page that is loading very slow. There is not a lot of data, not a
lot of users are connected at the same time and the page does not produce an
error, so I am not sure where to start to look for why it is slowing down. I
thought about the DB first and added NOLOCK to a couple of stored procedures
that were being run, but with no...
|
by: Nicolas R |
last post by:
Hi all,
Im trying to figure out how to display a 'loading' message when
scripts are being executed, ie when the page is still not ready for
interaction. This is for a web app which relies on javascript to
insert dom elements and do stuff, so the user must know when
everything is ready to interact with.
I tried using an interval which...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| | |