I spent yesterday optimizing the performance of this site. I love fast page loads and have little patience for sluggish performance. Here’s what I did.
1. Leverage browser caching
Tell your web server to set expiration headers for static resources so browsers know to store them in local disk. This will keep requests off the network altogether. I use Apache:
1 2 3 4 5 6 7 8 9 10 11 |
|
2. Remove Query Strings From Static Resources
Query strings like ?ver=3.3
can prevent proxies from caching. Some WordPress plugins automatically generate these query strings when calling stylesheets and JavaScript files. I removed them with:
1 2 3 4 5 6 |
|
3. Reduce Number of CSS/JS Files
I consolidated my external CSS/JS files because each separate file is a separate request to the server.
4. Use WordPress Super Cache Plugin
This plugin generates static HTML from WordPress’ PHP scripts and serves those instead. I scheduled it to preload pages and refresh them once a day.
5. Use Memcache with WordPress
Reading from memory is orders of magnitude faster than reading from disk. This is a good analogy of the difference from the computer’s perspective.
I have the PECL memcache extension and memcached daemon running on localhost’s port 11211.
I put this in wp-config
:
1 2 3 |
|
and object-cache.php
in wp-content
.
6. Test Your Site’s Speed
Pingdom is a good tool. Here’s my site’s performance history.
Resources: