I have an Apache 2 on Centos + bind with a wordpress website on it (e.g example.com). I have also set up, on another server in a different country a load balancer (varnish:80 + nginx for it - which task is to server all static content under /wp-content/.

Using Simple DNS editor I added an A entry to cdn.example.com pointing to the server's IP. So no extra work from a 2nd dns server.

Then using htaccess I redirect all requests to jpg|gif|css|js files to cdn.example.com. That works and all files are saved on the "cdn" server and served right away.

My problem is that for the first time I enter on example.com (e.g after restarting the computer or closing the browser) the load time is 1 up to 3 seconds, while any subsequent page loads take only 300 to 600 miliseconds.

I know it might be a DNS issue, but I have done a cache check on several websites and cdn.example.com indicates the right IP.

Do you have any ideas where I should dig to solve this first-time slowness?

Later edit:

I made a static version (.htm) of my index.php and tried some tests on it. And I noticed something interesting: some images load very slow.

As I've seen in Google Developer tools: Waiting _ _ _ _ _ _ 3.04s. That's not good, maybe varnish is experiencing some issues...

  • What's wordpress first page load time, to begin with? Assuming cold php opcode cache, mysql query cache and other caches
    – 3molo
    Jun 1, 2012 at 10:54
  • woo, wordpress load time (whithout the "cdn" usage) is an average of 2 seconds. But I don't think that's the problem since once plugged in the so-called "cdn" speeds up the website to 300 miliseconds. So dynamic content actually takes very short time to load, right?
    – adrian7
    Jun 1, 2012 at 11:50
  • 1
    First request will take as long as the "backend" takes, plus some overhead. Then subsequent requests will go fast, given that they are cached (and that the problem is the backend response, and not network/latency issues between client and whatever is in front of the backend).
    – 3molo
    Jun 1, 2012 at 14:10

1 Answer 1


You should use a tool like the developer tools in Chrome to see which parts of the page load are taking all the time. Is it the initial response, or is it all the subsequent queries for JavaScript, CSS, images etc..

If it's the initial response that is slow then it's a Wordpress issue, and no CDN can help. If it's all the other stuff, then you need to take another look at how your CDN is working.

If you fear DNS is a problem, try benchmarking the DNS response times. Be sure to point what ever client you are using for the benchmarking at your authoritative server, so that you are not seeing cached responses.

The chances are, it's wordpress being slow, in which case, you may need to eliminate plugins, or, to get better hardware.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .