1

I have a site where a page takes 10 seconds to load with firefox, and a further 10 seconds to load the images. It's a php page running on apache. The Images are just static images.

It runs beautifully on chrome.... instant loading.

googling for the answer has pointed me towards a possible issue with keep alive and the lack of content length confusing firefox, and indeed, it appears that content length isn't being set by the server on either the static or non static content, but disabling keep alive on the server doubles the load time!

Some sites have suggested disabling keep alive on the browser, but I'm reluctant to recommend that to everyone that views the page! Am I perhaps barking up the wrong tree?

browser is firefox 3.6.8 on Lucid Lynx. server is Apache 2.2.11.

apache.conf is apended... I think it's the one that comes out of the box, although I reduced the KeepAlive timeout to 3 in a vain attempt to try and get the page to load.

Am I barking up the wrong tree?

ServerRoot "/etc/apache2"

LockFile /var/lock/apache2/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 3
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>
<IfModule mpm_worker_module>
    StartServers          2
    MaxClients          150
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
AccessFileName .htaccess
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>
DefaultType text/plain
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel warn
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined
Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/
ohp
  • 121
  • 2
  • 10
  • Can you link to the actual site? Is it heavy JS? – meder omuraliev Aug 06 '10 at 22:57
  • I've set up a test site at http://www.farnthropkelly.co.uk/ – ohp Aug 07 '10 at 11:56
  • I've posted up some timings on that site... DNS lookup is fine.. Currently I'm minded to think this is a strange firefox bug.. Will try this on a windows version of firefox, and perhaps IE, or different versions of firefox. – ohp Aug 07 '10 at 12:46
  • I've been running the tamper data tool with lots of other sites, and it looks like this is a problem my firefox install has with many sites, but had been masked by local cacheing. This may be a local network issue. – ohp Aug 07 '10 at 13:07
  • "a possible issue with keep alive and the lack of content length" - could you provide any references for this? TIA – symcbean Aug 11 '10 at 15:13

2 Answers2

2

The issue was with local DNS lookup. The issue was hidden by the fact that command line DNS resolution seemed to be OK, and chrome was lightning fast. Turns out that chrome uses DNS prefetching, which doesn't use the local network stack. This threw me onto completely the wrong tack.

After creating a local bind service, firefox seems to be working nicely.

So something to watch out for when running chrome on the same platform as other browsers.

ohp
  • 121
  • 2
  • 10
1

Don't disable keep-alive. It makes that one connection can be used to get multiple pages (or images, or .js files, or .css files, etc.), which reduces page load time significantly.

Just make sure your scripts add Content-Length headers and all will be fine.

mvds
  • 45,755
  • 8
  • 102
  • 111
  • I'll have a look at the php script, but Shouldn't apache be adding the content length to static files? Come to think of it, I've never had to manually add content length to a php file either... – ohp Aug 07 '10 at 10:19
  • Apache should do that, yes. But just start with fixing things that are easy. The content-length issue can cause trouble with chunked transfers, https, and all kinds of weirdness I've seen over the years. Just do it by the spec: specify a Content-Length. – mvds Aug 07 '10 at 10:35
  • am reading the wc3 spec at http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html which says that the content length should be set when the content length is known prior to transmission. If the content is dynamically generated, what's the best practice for determining the value? And how can I get apache to set the content length for a static graphic file? – ohp Aug 07 '10 at 12:09
  • don't know about apache, I think it will set content-length when keepalive is on. Getting content-length from a php script, in general (as an example) is done by calling ob_get_length() after you're done generating output. (yes you must use output buffering in that case) In some cases you may know content-length in advance. – mvds Aug 07 '10 at 12:25
  • OK, I have the same problem with static files, and the server is serving content-length headers, so I'm going to shelve this line of enquiry for the time being. I've posted relevant data on the test site. – ohp Aug 07 '10 at 12:38
  • You probably have static and dynamic pages on the same host, and therefore within the same connection, and the dynamic ones mess up things for the static ones. Just add that content-length header. – mvds Aug 07 '10 at 13:00
  • see the test site. It's purely static. – ohp Aug 07 '10 at 13:04
  • Oh that link. Sorry, can't reproduce any problem with that, it just works! – mvds Aug 07 '10 at 14:26
  • That's why I reckon it must be s specific issue with my firefox install. – ohp Aug 07 '10 at 15:21