Slow sites are one of the most frustrating parts of running a blog. When I started with WordPress, there was little more I knew than adding a caching plugin and GZip plugin. In the years since, I have found awesome methods to get a great Google PageSpeed score and make my site load lightning fast, or at least a lot faster than today.
WP Super Cache
There are a few go-to caching plugins available, but my best experience has been with WP Super Cache.
Make sure to set the options to what is best for your site and your server settings. For most people on shared WordPress hosting, which is most WordPress users, the “recommended” options usually work best. Make sure to turn on mod_rewrite caching and set an expiry time (I use 3600 seconds), turn on preload settings if your site doesn’t get tons of new content all the time, and check the boxes for plugin compatibility for anything you’re using.
Autoptimize is another plugin for speed and overall site awesomeness. I generally suggest avoiding excess plugins where possible, but this one does some serious heavy lifting for you that custom code is not practical for.
The plugin helps you minify your CSS and PHP, inline your CSS, optimize your HTML code, and rearrange how your code is sent to browsers for faster loading times.
Not sure what that all means? No need to worry about it with Autoptimize. And, if you find that some elements are not working right, you can just add a line of code to skip autoptimize on that element. You can find details and FAQs on the Autoptimize page at WordPress.org.
EWWW Image Optimizer
Big images can slow down your site. A lot. The EWWW Image Optimizer plugin uses advanced image compression scripts to resize and optimize your image files for the web.
The images will look the same, but will load much faster, after you run them through the mass optimizer tool.
(Updated 3/27/2015. Replaced Smush.it with EWWW Image Optimizer)
Leverage Browser Caching
Now we are going to leave plugin land and get your hands dirty with some code editing. Don’t worry, it is very easy. First, open your .htaccess file in the main folder of your WordPress installation on your server. You can do this through your hosts CPanel or with an FTP program like Filezilla.
Open the file with your favorite text editor and add the code below at the very top of the file. Remember to save a backup copy before editing in case something doesn’t work as expected.
This code will tell visitor’s browsers to keep certain elements of the site locally in the user’s browser cache so they don’t have to reload the entire site each visit, and some elements that are on each page are already there as well.
Enable GZip Compression
While you have .htaccess open, let’s add GZip compression to take out extra spaces and unnecessary parts of the code. You can use the code below to add GZip compression. Make sure to add it after the Super Cache code and before the line that says # BEGIN WordPress.
One of the biggest improvements I have ever made for my site was to leave the discount host and sign up for something better. My site speed increased about 80% with that one change. Learn more about setting up your website here.
A CDN is a content delivery network. For a fee, some companies will host your site on servers all around the world and will send from the closest location to each visitor. For heavy traffic websites, a CDN is a great investment.