Google Answers Logo
View Question
 
Q: PERL script: image file rendering delayed. Why? ( No Answer,   2 Comments )
Question  
Subject: PERL script: image file rendering delayed. Why?
Category: Computers > Programming
Asked by: marcfest-ga
List Price: $50.00
Posted: 26 May 2003 16:04 PDT
Expires: 29 May 2003 22:25 PDT
Question ID: 209082
Please view http://www.onlinehomebase.com/test.cgi

test.cgi contains the following perl code:

#!/usr/bin/perl

print "Content-type: text/html", "\n\n";
print "x<br><img src=\"topleft_CCFF66.gif\" width = \"7\" height =
\"7\"><br>\n";
print "x<br><img src=\"topright_CCFF66.gif\" width = \"7\" height =
\"7\"><br>\n";
print "x<br><img src=\"bottomleft_CCFF66.gif\" width = \"7\" height =
\"7\"><br>\n";
print "x<br><img src=\"bottomright_CCFF66.gif\" width = \"7\" height =
\"7\"><br>";
exit;


PROBLEM:

For some reason, when rendering
http://www.onlinehomebase.com/test.cgi, there will always be one image
that the browser will "hesitate" to display, while all other display
promptly. This happens consistently.

I would like to get rid of this delay and have all image display
quickly.

The reason is NOT that one of the image files loads slowly: Go to
http://www.onlinehomebase.com/x_test4.html (which contains the same
html as is served by the test.cgi), and all images load fast.

Furthermore, when commenting out ANY three images in test.cgi, as done
in http://www.onlinehomebase.com/test2.cgi , the one remaining image
(no matter which one it is) will ALWAYS display with a delay. It's as
if something causes the "last" image to always be displayed with a
delay, IF the html is served up by a script.

Could it be that the script needs to close some kind of connection to
the browser so that the rendering for the "last" image (however the
browser or server defines "last") is not delayed?

What is going on here?

Thank you for helping.

Marc Fest

Request for Question Clarification by arimathea-ga on 26 May 2003 17:38 PDT
marcfest-ga,

Does this happen with all browsers?

Clarification of Question by marcfest-ga on 26 May 2003 18:04 PDT
I've been testing this with IE 6.0 under Windows. Don't know if this
happens with other browsers as well. IE 6.0 / Win is what I am
concerned about.

It have reproduced the behavior on various PCs.

Request for Question Clarification by errol-ga on 26 May 2003 18:28 PDT
Hi!

Just to let you know, I've reproduced the problem with Mozilla/WinXP Pro.
It appears that it is the Perl script, web host or the server itself causing this.

Regards,
errol-ga.

Clarification of Question by marcfest-ga on 27 May 2003 04:32 PDT
Eadfrith - 

Thanks so much for looking into this. test3.cgi uses the code listed
below, with an additional newline, but it does not seem to make a
difference. I do have a hunch though, that you are on the right track.
It'd be great if you figure this out.

Best,

Marc.

++ 

test3.cgi:

#!/usr/bin/perl

print "Content-type: text/html", "\n\n";
print "1<br><img src=\"topleft_CCFF66.gif\" width = \"7\" height =
\"7\"><br>\n";
print "2<br><img src=\"topright_CCFF66.gif\" width = \"7\" height =
\"7\"><br>\n";
print "3<br><img src=\"bottomleft_CCFF66.gif\" width = \"7\" height =
\"7\"><br>\n";
print "4<br><img src=\"bottomright_CCFF66.gif\" width = \"7\" height =
\"7\"><br>\n";
exit;

Clarification of Question by marcfest-ga on 27 May 2003 10:33 PDT
For your information: I installed the same script on a different
server (but referencing the same image locations), and all displays
normally, without the delay of the one image. See
http://www.quickbrowse.com/gt.cgi

So it seems to be a server-specific setting.

I'm upping the reward for this to $50.

Marc.

Request for Question Clarification by sgtcory-ga on 29 May 2003 12:35 PDT
Hello marcfest,

I have a suggestion to test, but can not pinpoint the exact cause
quite yet. On one server you are running Apache 1.2.19 (slow image),
and on the other Apache 1.2.22.

I tested this on my server which is running Apache 1.2.27 and it
worked like a charm.

The only thing I can suggest as a test, is to upgrade Apache on the
slow server and run it again. If it works we can start to dig deeper.
I have been searching for something along these lines that may be a
known problem, and will keep you informed of how it goes. There is
quite a large amount of documentation on the changes from version 19
to 22, and it may help lead us in the right direction.


SgtCory

Clarification of Question by marcfest-ga on 29 May 2003 22:25 PDT
I've noticed that using a different domain on the same server for the
same script does not show the problem.
http://www.onlinehomebase.com/test.cgi shows it while
http://www.marcfest.com/test.cgi does not. The problem must therefore
lie with the virtual container for onlinehomebase.com in httpd.conf.
I'm sure I'll figure it out now that I've narrowred it down to this.
thank you again to all that have tried to help me.
Answer  
There is no answer at this time.

Comments  
Subject: Re: PERL script: image file rendering delayed. Why?
From: eadfrith-ga on 26 May 2003 21:41 PDT
 
Markfest,

The problem could be the missing newline on your last print statement.
I even have a wild theory as to why this would cause the behaviour
you're seeing.

The first thing I did to test your script was to check the headers
being returned using this very useful site:

http://www.delorie.com/web/headers.html

I noticed that the content-length header was missing when your script
was being served (if you check the headers from your static html file
then you'll see that the content-length *is* set). This could
definitely cause the problem you're seeing, since the browser doesn't
know how much data to expect and so has to wait for a certain amount
of idle time before concluding that the page is complete.

Now, as to why the content length isn't being set. I'm not absolutely
sure, but I have an idea. As you may know, perl, by default, buffers
all output so that it can determine the content length and send it in
the header (as per the HTTP specification the headers must be sent
before the data). Your missing newline could be causing perl to get
confused about when the data is complete and so it never determines
the content length.

So, try adding the newline to the last print statement. If this
doesn't work then we can look further into why the content-length
isn't being set.

By the way, I wrote some Java code that connects to your script and
reads the content directly, just to check that there wasn't a delay
before the last image tag was being received (you can't determine this
from a browser). All of the data came through blindingly fast (0
milliseconds to be precise!) so there's no problem there. I definetly
think the issue is the missing content-length header.

Cheers,

Eadfrith
Subject: Re: PERL script: image file rendering delayed. Why?
From: eadfrith-ga on 27 May 2003 11:21 PDT
 
Markfest,

Too bad the simple newline didn't fix the problem. Always worth trying
the simple things first though.

I have good news and what could be bad news. The good news is that
there's nothing wrong with your script, as you've found by running it
on another server. The bad news is that I believe you're encountering
a bug in the way that Apache handles cgi scrips.

Here's a link to the bug report:

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7617

and a fix that has been submitted, although unfortunately it's in the
form of a patch to Apache, not a workaround that you can put in your
script:

http://groups.yahoo.com/group/new-httpd/message/40597

I believe these posts describe your problem pretty well, especially
the patch report.

The bug page asserts that the fix should be available as of Apache
2.0.44, but I checked the change logs for Apache up to and including
2.0.45, the current release, and couldn't see any reference to this
bug being fixed. Just to be sure I downloaded the source for 2.0.45
and checked to see if the patch has been applied, and it has.

Is it possible for you to test this idea by installing Apache 2.0.45?
If not then you may have to live with the delay, or switch to another
server.

Cheers,

Eadfrith

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy