Optimizing WordPress

Optimizing WordPress

If you use a managed host, there won’t be as much to do to optimize your WordPress site. If you self-host, there’s a lot that you need to do.

Caching and Scaling

If your site receives thousands of requests, WordPress will struggle to build each page dynamically for each reader. It’s best practice to use some caching solution – so that most pages are stored on disk or in memory and served directly to your readers when they request them.

I’ve written an extensive guide to using Varnish Cache with the W3 Total Cache plugin on Apache. I find that this is an extremely straightforward, robust solution to scaling. This site regularly receives traffic from popular sites such as Slashdot, BoingBoing and Salon, sometimes simultaneously – and my caching configuration almost always handles this smoothly.

Because caching works primarily with readers that are not logged into your WordPress site, it’s useful to use a cacheable comment system besides WordPress, something like Disqus. This ensures that a higher percentage of page requests are served from your cache.

Content Delivery Network (CDN)

W3TC also integrates well with various content delivery networks (CDN). A CDN duplicates and distributes your content geographically to speed delivery of regularly used files such as theme css, javascript and media files. Using a CDN greatly reduces the number of inbound requests to your WordPress server. Read my guide to integrating Amazon’s CloudFront, which I use with this site.

Setting up custom subdomains on an alternate domain from your primary site can speed delivery of CDN content. For example, my CDN serves from a different domain entirely than jeffreifman.com so that cookie data is not carried along with each file request.