Optimizing Your WordPress Website

Minimizing Plugins

The first and easiest way to improve WordPress performance is by looking at the plugins. Deactivate and delete any unnecessary plugins. Try selectively disabling plugins to measure server performance.

Is one of your plugins significantly affecting your site’s performance? Look at the plugin documentation or ask for support in the appropriate plugin support forum.

Optimizing content

  • Image Files
    • Are there any unnecessary images? (e.g. Can you replace some of the images with text?)
    • Make sure all image files are optimized. Choose the correct format (JPG/PNG/GIF) and compression for each image.
  • Total File Number/Size
    • Can you reduce the number of files needed to display the average page on your site?
    • When still using HTTP1, it’s recommended to combine multiple files in a single optimized file.
    • Minify CSS and JavaScript files. 

You can also offload content to optimize your theme.

Upgrade Hardware

Paying more for higher service levels at your hosting provider can be very effective. Increasing memory (RAM) or switching to a host with Solid State Drives (SSD) e.g. Digital Ocean can make a big difference. Increased number of processors and processor speed will also help. Where possible, try to separate services with different functions – like HTTP and MySQL – on multiple servers or VPS-es.

Optimize Software

Make sure you are running the latest operating system version e.g. Linux, Windows Server and the latest web server e.g. Apache or IIS, database e.g. MySQL server and PHP.

Perhaps you are unable to perform the tasks, and follow up on the tips, below. Just ask your hosting provider to do them for you. A good hosting provider will upgrade or move your account to an upgraded server, to match the recommendations. If needed you can switch to a managed WordPress hosting solution.

DNS: Don’t run a DNS on your WordPress server. Use a commercial service for DNS such as Amazon’s Route 53 or your domain registrar’s free offering. Using a service such as Amazon can also make switching between backup servers during maintenance or emergencies much easier. It also provides a degree of fault tolerance. If you host your DNS on external servers this will reduce the load on your primary web server. It’s a simple change, but it will offload some traffic and cpu load.

Web Server: Your web server can be configured to increase performance. There are a range of techniques from web server caching to setting cache headers to reduce load per visitor. Search for your specific web server optimizations (for example, search for “apache optimization” for more info). Some web servers have higher speed versions you can pay for such as Apache Litespeed. There are also a number of ways to tune Apache for higher performance based on your particular hosting and site configuration, e.g. Memcache.

PHP: There are various PHP accelerators available which can dramatically improve performance of your PHP files. This will apply to all PHP files, not just your WordPress installation. Search for PHP optimization for more information, f.e. APC or OPcache. The W3 Total Cache plugin, described below, offers integrated support for Memcache, APC and other Opcode caching.

MySQL/MariaDB: MySQL or MariaDB optimization is a black art in itself. A few simple changes to the query cache settings can have a dramatic effect on WordPress performance because WordPress repeats a lot of queries on every request. Nowadays, with InnoDB being the default storage engine for MySQL, you have to make sure to use that. InnoDB can be optimized and fine-tuned, search for “mysql optimization”, “mysql innodb performance” or “innodb optimization” or for more information and examples. Search for “mysql convert myisam to innodb” for information on how to convert older MyISAM tables to InnoDB.

A great example of how WordPress has been optimized was presented by Iliya Polihronov at WordCamp San Francisco 2012. Iliya does, among other things, server optimization for WordPress.com.

Don’t run a mail server on your WordPress server. For your contact form, use something like Contact Form 7 with free Mailgun.


Caching Plugins

Plugins like W3 Total Cache or WP Super Cache can be easily installed and will cache your WordPress posts and pages as static files. These static files are then served to users, reducing the processing load on the server. This can improve performance several hundred times over for fairly static pages.

When combined with a system level page cache such as Varnish, this can be quite powerful. If your posts/pages have a lot of dynamic content configuring caching can be more complex.

W3 Total Cache

W3 Total Cache (W3TC) is the latest generation in WordPress performance plugins, combining the research of web development authorities to provide an optimal user experience for WordPress sites. These detailed guides walk you through

W3TC is unique in its ability to optimize server side and client side performance, adding functionality otherwise unavailable natively:

  • Page Caching: W3TC helps to decrease response time by creating static HTML versions of pages, allowing web servers to serve them without invoking PHP. It automatically updates the cache when comments are made or pages are edited.
  • Minification: Removes unnecessary characters from HTML, CSS and JavaScript files, then respectively combines them before applying HTTP compression on the cached files.
  • Database Caching: Database queries (objects) are also cached, allowing many sites to reduce the time needed to generate new pages. This is especially useful for sites that receive a lot of comments.
  • Headers: W3TC manages the headers (entity tag, cache-control, expires) which control the caching of files in web browsers, reducing server load and improving the user’s perceived performance.
  • Content Delivery Network (CDN): Using a CDN allows you to Offloading resources from your hosting account. W3TC moves the requests for images, CSS, JavaScript and other static files to a network of high performance servers. The server closest to the visitor is automatically used to download the files, providing the fastest downloads possible.

W3TC can be used to optimize WordPress in both single- and multi-server environments through either shared or dedicated hosting.

WP Super Cache

WP Super Cache is a static page caching plugin for WordPress. It generates HTML files that are served directly by Apache without processing comparatively heavy PHP scripts, helping you to make significant speed gains on your WordPress blog.

Using WP Super Cache allows your server to serve cached HTML pages at the same speed it serves regular graphic files. Consider WP Super Cache if your site is struggling to cope with its daily number of visitors, or if it appears on Digg.comSlashdot.org or any other popular site.

Server-side Caching

Web server caching‘ is more complex but is used in very high traffic sites. A wide range of options are available, beyond the scope of this article. The simplest solutions start with the server caching locally while more complex and involved systems may use multiple caching servers (also known as reverse proxy servers) “in front” of web servers where the WordPress application is actually running. Adding an opcode cache like Alternative PHP Cache (APC) to your server will improve PHP’s performance by many times.

Varnish Cache works in concert with W3 Total Cache to store pre-built pages in memory and serve them quickly without requiring execution of the Apache, PHP, WordPress stack.

As described within, using a plugin for comments such as Disqus instead of native WordPress comments can assist Varnish by not requiring your readers to login to WordPress and increasing the number of page views that Varnish can serve out of the cache.

Browser Caching

Browser caching can help to reduce server load by reducing the number of requests per page. For example, by setting the correct file headers on files that don’t change (static files like images, CSS, JavaScript etc) browsers will then cache these files on the user’s computer. This technique allows the browser to check to see if files have changed, instead of simply requesting them. The result is your web server can answer many more 304 responses, confirming that a file is unchanged, instead of 200 responses, which require the file to be sent.

Look into HTTP Cache-Control (specifically max-age) and Expires headers, as well as Entity Tags for more information.

W3 Total Cache integrates support for browser caching and ETags.

Persistent Object Cache

A Persistent Object Cache helps speed up page load times by saving on trips to the database from your web server. For example, your site’s options data needs to be available for each page view. Without a persistent object cache, your web server must read those options from the database to handle every page view. Those extra trips to the database slow down your web server’s response times (TTFB) and can quickly overwhelm your database server during traffic spikes.

For your site to use persistent object caching, your hosting provider must offer you a particular type of server, a cache server. Popular cache servers are Redis and Memcached. Ask your hosting provider to help you install and configure a persistent object cache, and they will recommend the right plugin, such as:

  • Memcached Object Cache – Provides a persistent backend for the WordPress object cache. A memcached server and the PECL memcached extension are required.
  • Redis Object Cache – Provides a consistent Redis object cache backend for WordPress that works with various Redis clients. A Redis Server is required.