I’ve never been a fan of IDEs, complex debugging tools with breakpoints, variable watch lists and all that fancy stuff. var_dump() and print_r() have always been my best friends. Recently I was playing around with the caching arguments in WP_Query, trying to combine that with update_meta_cache() while sticking wp_suspend_cache_addition() somewhere there in the middle, and it quickly became...
An Alternative to @import in WordPress Child Themes
Using Child Themes in WordPress is a great way to modify an existing theme, however the CSS @import directive is slower than it has to be, so you should try and avoid it. Here’s why. If it takes 200ms to load the child theme’s stylesheet, and 200ms to load the parent theme’s CSS, a modern web browser should take approximately 200ms to load both of them, because modern browsers...
High Performance WordPress
A co-worker and friend of mine Iliya Polihronov gave this talk earlier this year at WordCamp San Francisco 2012. He walked through an optimal server configuration for a high-performance WordPress environment, including nginx, php-fpm, APC and memcached. His notes are on SlideShare. I’ve been running an nginx and php-fpm configuration for over a year now, with a VPS from MediaTemple. I tried...
Otto on Caching in WordPress
Otto describes why neither page caching, nor persistent object caching are part of the WordPress core, and why they probably never will be. The main reasons are the way WordPress is architected, and the way it is used by the majority. If you’re a person writing a blog that gets less than 1000 hits a day, caching ain’t going to do much for you. And my favorite, about why object cache...
10 Things to Speed up WordPress
Ross Johnson talks about the importance of page load times in today’s world. CSS and JavaScript compression, clean HTML and compressed images, CSS sprites, page and object caching, content delivery networks and more. If your WordPress site is slow, watch this video for a handful of tips on how to make it faster.
Get an Expired Transient in WordPress: Good Idea or Crazy Talk?
I wonder if there’s an easy way to get an expired transient in WordPress? Now, for this to make sense I guess I should provide a little more context, so here it goes :) The Transients API is an extremely easy way to cache parts of your WordPress code, that may be CPU/memory intensive, or rely on a third-party server and so on. A great example is grabbing a tweet from Twitter and caching it...
Google Analytics Proxy with Nginx
Here’s a quick tip! If you need to serve a specific script, stylesheet or any other file from your own domain, you can easily proxy it with nginx. A good example is the ga.js file for Google Analytics. Here’s how I proxy it with nginx, in the server context: # Google Analytics Proxy rewrite ^/ga.js$ /ga/ last; location /ga/ { proxy_pass ; break; } This rewrites the ga.js filename to...
Varnish and Preview Posts in WordPress
I wrote earlier that I started playing around with Varnish here on my site and that post has a little snippet that strips all incoming and outgoing cookies (except the admin of course.) Today I stumbled on a problem where I had no permission to preview a post I was drafting in WordPress and they all turned 404’s when I tried to. I first thought Varnish was stripping out the preview query...
Varnish and WordPress Comment Cookies
I wrote before that I’ve been running some experiments with Varnish lately. Not that I have huge traffic here but I’ve always used my own website to test things out. As I wrote earlier, the problem with WordPress and Varnish is that WordPress relies on cookies which create cache misses on Varnish and in that previous post I shared a snippet on how to strip all incoming and outgoing...
My website is now super-fast with Varnish
My website is now super-fast with Varnish — an open source HTTP accelerator which sits on top of your HTTP servers and serves your cached pages. It didn’t take me longer than 20 minutes to get Varnish up and running on my Ubuntu VPS, and a few more minutes to set all my nginx configurations to port 8080, bringing Varnish to port 80. The problem with WordPress however, is that it...