First pageload slow; browsing speedy thereafter

Hi all

I have a bizarre problem whereby when I first browse to my c5 dev site, the first page load takes quite a while (up to 5-6 seconds), but thereafter things are nice and speedy (including on the initial page that I browsed to).

I've tried to improve matters by enabling Apache gzip in .htaccess, but that hasn't solved the problem of the first-page-load-delay.

It's annoying because obviously the first pageload is the first impression, so it's important that it is snappy. It doesn't happen every time, either. If after browsing for a bit, I close the browser (or open a different browser) and navigate back to the site, it's still snappy. It's like the server needs to 'wake up' the first time the site is accessed after a dormant period.

Here's the URL if anyone's interested:

btw I have the cache enabled and logging of exceptions disabled. The site is also in 'production' mode. I'm running

Any help or ideas would be much appreciated :)

View Replies: View Best Answer
Mnkras replied on at Permalink Best Answer Reply
try compressing your images :P also you have 1 div tag thats open and put the mime types in the in.php
melat0nin replied on at Permalink Reply
Thanks for the reply, will try that. I did some tests and yeah, the images are a bit big. Also I need to set cache expiries for stuff, perhaps that has a problem.

Can you explain re the Mime types?
Mnkras replied on at Permalink Reply
right now some are like this:

<link rel="stylesheet" href="/something.css" />

it should be like

<link rel="stylesheet" type="text/css" href="/something.css" />

heres a complete list of mime types
melat0nin replied on at Permalink Reply
Hm I don't see that, both my templates have the css mime types set correctly :-/

What do you mean by in.php? i.e. homepage?
htarlov replied on at Permalink Reply
I have the exacly same issue. It's happenng on all web pages hosted with my hosting provider (

It's pretty irritating. I will try other hosting provider soon. It's some server side problem and I doubt that a change in HTML code or images size will help.

One notice: it waits a few seconds before it even sends some HTTP headers back to the browser. So it's not an issue with something after loading HTML part (CSS, JS, images).


I provide a firebug screenshot:


That's strange. I've put out some timing info from dispatcher and database modules. And that's what I found:

From database:

/START/ select timestamp, cfValue from Config where cfKey = ? : 0.96540284156799
/END/ select timestamp, cfValue from Config where cfKey = 'ENABLE_LOG_ERRORS' : 0.96936392784119
/START/ select timestamp, cfValue from Config where cfKey = ? : 8.0839309692383
/END/ select timestamp, cfValue from Config where cfKey = 'URL_REWRITING' : 8.0861220359802

So it's 7 seconds between those 2 queries.

From dispatcher:

[startup config check:0.38580298423767]
[app config:8.2778789997101]

So it's somewhere in app.php in config.
In code it happens here:

if (!defined('ENABLE_LOG_ERRORS')) {
   Config::getOrDefine('ENABLE_LOG_ERRORS', true);
# Default URL rewriting setting
if (!defined('URL_REWRITING')) {
   Config::getOrDefine('URL_REWRITING', false);

Performance problem pops into existence in one of those getOrDefine, but not during a SQL call (those are fast).
I thinkt it's very strange behavior.
I will need further investigation so I maybe will find out on which exact line it stops for such a long time and if it's always the same line.