A good way to improve the speed of your Web site is through caching different types of content. Caching content means to store it transparently so that it can be used for future loads of your Web site. A good caching system for your Web site collects all the Web pages on your site and copies, stores, and delivers the files to visitors of your Web site. This significantly reduces the server load because without it, WordPress creates pages on your Web site dynamically — each time a visitor loads your Web site, calls are made to the database and code is complied and executed each time to create the page in her browser. If you use a good caching program, those files are already built and displayed, so your Web server doesn't need to rebuild those pages each time.
The following are the different types of caching that can improve your site performance:
You can also improve the speed of your Web site through minifying — making some of the files, like JavaScript, CSS, and HTML, smaller. This involves taking all the files of your Web site and reducing the size by doing things like
Minifying JavaScript, CSS, and HTML files reduces the overall file size, making them load faster on your Web site. Obviously, adjusting each of the existing files on your site to make them smaller would take quite a lot of time and programming skills that you may or may not possess. Therefore, you may prefer to use a plugin or program to adjust these files. A good plugin or program used to minify files can reduce the file to 30–40 percent of its original size, which greatly improves the response time of your Web site.
Figure 5-2 shows the HTML source code from Lisa's Web site in its regular state, and Figure 5-3 displays it in a minified state. You can see how minifying shrinks the size of the overall file by removing spaces and line breaks, and shortening the characters used.
Use a WordPress plugin (such as W3 Total Cache (http://wordpress.org/extend/plugins/w3-total-cache) that has a feature that minifies files, such as JavaScript, CSS, and HTML, by caching the minified files. This leaves the original files intact so they are easily readable and editable by you.
A content delivery network (CDN) stores your Web site data within different points on a network and can deliver that data to Web site visitors with a decreased amount of bandwidth. A CDN can choose to deliver this data from the nearest geographical location, making the transfer faster. Because of this, visitors don't access the data from the same place at the same time, which lightens the load on your server significantly.
To use a CDN, you need to sign up for a service that provides a network and a series of computers to store and serve your data on your Web site. The CDN can include items like images and CSS, JavaScript, and media files. Using a CDN reduces the load on your server because the files are delivered through the CDN, not through your Web server. This is especially helpful if you use a significant amount of bandwidth on your current hosting account.
CDN services are relatively inexpensive, particularly if you don't have a lot of media files, images, and data to store on their servers. A few popular CDN providers include
The benefits of running a content delivery network include the following:
In the next section of this chapter, we give you a couple of plugins that provide a user interface to help you set up a CDN on your Web site. Just remember that CDN services aren't free, and the costs vary depending on the service provider that you use.
We recommend these two plugins, which provide you with the best and easiest ways to make sure that your WordPress site has a caching system in place: