WordPress Caching – Super Cache, Wassup Analytics, and PHP Opcache Oh My
This site was taking 20 seconds to load from an empty cache state. I would empty the cache, and the first time a page was generated it took nearly 20 seconds to push out anything.
First a tiny bit of background.
A ton of stuff goes into the chain of events preceding a webpage appearing on your web browser. Let’s just say it’s complicated – from the operating system’s resources running the webserver, to the database, how it’s tuned, to the rendering engine, to the application as it’s written. Whew. With that said, PHP 5.5 with its opcache is very nice. What it does is cache a compiled version of the application so that it doesn’t have to fetch it and compile it on the fly. We use it for Drupal and WordPress and it gives a snappy performance even on very limited resources.
So take this site for example, Super Cache is a WordPress plugin that is designed to provide a pre-rendered HTML page so that the app doesn’t have to create it from scratch. Even with PHP’s opcache this is still relatively heavy. For content that doesn’t change every single refresh or need to for anonymous users, it gets you to the information you want without having to wait.
So why was the site taking nearly 20 seconds to load from a state of empty cache? I would note that if the cache was empty, the first page load took nearly 20 seconds.
Long story short, it was Wassup, an analytics plugin for WordPress. It’s pretty nice, but I haven’t used it much recently as I like awstats better. Once Wassup was deactivated first page compile times went from 20 seconds to a few milliseconds.
Now, why was this happening? I don’t really have the time to dig into Wassup to figure out at what point it was slow. Was it slow because of some remote API call? I don’t know, but now that it’s identified, I’ll let someone else do the detective work.