• RyanWilliams

    (@ryanwilliams)


    Hi guys,

    I’ve done a lot of optimisation with WordPress, and it’s running really nicely. However, one thing I noticed is that when the blog isn’t loaded by anyone in a while the first load seems to take 8–10 times longer to load.

    For example, I can refresh my blog repeatedly and every time I’ll see something like this in the footer:

    <!– 22 queries. 0.118 seconds. –>

    However, leave it for a bit longer and it’ll be more like this:

    <!– 22 queries. 1.240 seconds. –>

    After loading that slowly once, it’ll return to the previous fast loading until it’s not visited again in a short while.

    I’m just wondering if anyone knows what exactly causes this behaviour. I would assume it’s some kind of caching, but I don’t know where. I haven’t enabled the WordPress object cache, nor do I use a caching plug-in. And just as a note, enabling WordPress’ caching does not seem to stop this happening.

    Ideally I’d like to be able to discern where the caching is occurring, and then maybe extend that time so it’s less likely anyone will encounter the slow load, and instead almost always receive the fast loads.

    And as another general note, network latency or anything like should be irrelevant here as the number that increases is WordPress’ internal generation time, not how long it takes me to download it — this occurs before any data transfer occurs whatsoever.

    Thanks in advance to anyone who can lend their expertise! 🙂

Viewing 1 replies (of 1 total)
  • I realize this is an old question, but I thought it deserved an answer. Any modern computer system has multiple layers of caching at play that are completely transparent to wordpress. Those execution times account encompass most of the operations required to serve a page request, so they could be growing for any of a number of reasons.

    When you first load the page, all the PHP code required to create it is loaded from disk before being parsed and executed. Operating systems will cache data read from disk in RAM so that subsequent accesses are faster. When you reload right away, the PHP files are already in memory. After a while though, they may get flushed from the cache, especially on a machine that’s being used by multiple users and multiple applications.

    Another possibility is that your webhost uses some sort of PHP accelerator. Before PHP can be executed, the files need to be parsed into something better understood by the PHP interpreter. It’s surprising how costly this operation is. Some PHP accelerators cache the parsed form and reuse it on subsequent requests.

    The database server also has caches which could speed up repeat access, and which will expire if the data isn’t accessed for a while.

Viewing 1 replies (of 1 total)

The topic ‘Speeding up the first load (PERFORMANCE)’ is closed to new replies.