Tutorial: How to speed up WordPress
Fast loading websites have a lot of benefits: Designing WordPress for speed usually results in a higher customer satisfaction and better SEO results. Why? Because Google and surfers hate to wait for slow webpages to load. Therefore it is generally a good idea to optimize your WordPress installation for faster page load times. During this tutorial I’ll guide you through the complete proceess on how to speed up wordpress.
As a rule of thumb every page of your website should load in less than two seconds. Most pages of larger websites load within 1 to 2 seconds. Unless you are using a larger WooCommerce installation within your WordPress site which typically loads a bit slower you should aim for the mentioned 1 to 2 seconds with two seconds being the maximum.
Here are the main areas to think about:
Identify your bottom line first
Before you start optimizing your website for speed you should (edit: you must) identify your baseline. It`s really easy to identify your current page loading times. Head over to pingdom (https://tools.pingdom.com/ ) and type in the full URL (e.g. your http://www.domaint.tld) of your WordPress website. Choose the closest pingdom server and wait until the results are loaded. Pingdom will come up with several helpful information for you.
- The absolute time your page needed to load. Does your site need more than 2 seconds? Are you in the mentioned range of acceptable 1-2 seconds?
- Pingdom will also give you a percentage how many websites (in the world) are slower – and how many are faster.
- Further down the page you’ll find some helpful tips on improvement areas – like expiration settings or minification options (we’ll talk about it later on)
- There is an even more technical breakdown of every single piece of your analyzed page (a bit I similar to the developer tools you can plugin to chrome or firefox)
Of course you could even measure your personal load times if you like. You should repeat the bottom line assessment at least two or three times –ideally at different times of the day. Note your results down in writing.
Before you start speeding up your WordPress installation let me explain what slows down your website and what elements make it faster:
Choosing your plugins wisely
While a fresh WordPress install is usually pretty fast, page load time increase over time and making your visitors wait longer. The main cause for it: too many installed and activated plugins! Before adding another plugin to your WordPress blog you should rather considering not to us it. Though many plugins add valuable functions to your website every additional plugin slows down your site.
Your WordPress theme optimized for speed
Typically you choose your theme to realize your design ideas. Therefore a good theme should be a good fit for both your visitors and yourself as a WordPress administrator. The downside of it: like plugins you pay a price in performance lost when choosing a feature-heavy theme. Especially commercial themes come with lots of features which you get used over time (and might think you can’t live without). For instance: The Newspaper Theme – which I use here at WordPress-expert.info – has lots of useful and sometimes adorable features. When it comes to page load times such a “monster” theme requires additional work like using a caching plugin to accomplish acceptable load times.
Tipp: Even if you are not a WordPress developer – just count the file size of your desired WordPress theme. It is located underneath the wp-content/themes folder. Generally speaking less size in megabytes is equivalent to less code and will result in faster page load times.
A plugin to identify slow plugins
It may sound counter intuitive at first but there are a few good plugins that you may enable from time to time in order to identify the main performance blockers of your site.
Plugins like plugin profiler (which is provided free by Goodady by the way – thanks guys) will give you a good understanding what your WordPress backend is doing and why.
Important note: p3 profiler itself is rather a monster plugin in size. You only should use it for a few minutes or hours only until you find your performance hungry plugins. Please de-activate P3-profiler after you identified the main show-stoppers among your plugins.
Using cache for faster WordPress
When it comes to caching most people are a bit confused at first. Caching does several tasks at the same time. Depending on the caching mechanism this may take place at the webserver your WordPress sits on, inside WordPress itself or you may use a content delivery network (CDN).
- WordPress cache plugins aim to make speed up WordPress itself. We’ll talk about this in a minute. There are lots of caching plugins out there. We’ll also discuss how you can use a caching plugin later on.
- A content delivery network (CDN) is generally a good concept for almost any website. When using a CDN you place your static content like images on larger networks operated by Amazon, Rackspace or Onapp – just to name a few.
- Most likely your webhosting provider already added some features to your apache or nginx webserver to make the server itself faster. This may already include caching programs like varnish or some apache or nginx modules like mod_pagespeed
Using a caching plugin:
A reliable caching plugin can speed up your site dramatically. It reduces the amount of time consumed by the program by generating pure html-files and storing them. We’ll discuss this in an instance.
Using a CDN for your WordPress site
Using and implementing a CDN to offload images and other static content is beyond the scope of this article. Check out the other blog posts I wrote about how to use a cdn for WordPress.
Ask your webhosting provider
It is very likely that your webhosting provider already installed a couple of apache plugins to speed up the webserver itself. Some webhosting panels like cpanel or plesk have useful features bundled with the software.
If you have file-access to your WordPress installation you might easily check what your webserver provides. Just copy a php-file containing the phpinfo() statement to your webserver and execute it. If you are non-developer you might simply install https://wordpress.org/plugins/wordpress-php-info/ and check its result.
Look for memcached or mod_pagespeed with the given result page. If you find them – great. If not contact your webhost and ask their support staff what they are providing.
Choose a hosting plan for speed
Without going into much detail about how to choose the right hosting plan: Look for fast SSD storage for both your files and mysql-storage. Generally SSD (solid state disks) are much faster than conventional harddisks.
There are tons of hosting services out there in the web – so just head over to Google and search for “Wordpress hosting” and make sure you check the testimonials on the webhosting company.
Your Roadmap to speed up WordPress:
As soon as you know your bottom line – let’s break down your page load times in detail:
Install P3 Performance Profiler and activate the plugin. Click on the settings page of P3-Profiler and start a scan. This may take several seconds or minutes depending of the size of your site. Using P3-Profiler you’ll identify the plugins that consume most of the time of your WordPress Site. Start with the one that consumes most of the time:
Ask yourself the following question:
- Do you really need this particular plugin?
- What value does the plugin provide for you and your visitors
- What would happen if you simply delete it – yes delete it!
- If you can’t delete it: Can you replace the plugin with a different one providing the same functionality with smaller amount of processing time needed?
Repeat this step for every plugin you’re using. If you have identified one or more plugins you can live without make sure you de-activate and delete it completely from your WordPress installation.
Why you need a caching plugin to make WordPress faster
As soon as you are done with the plugins let’s go over to leverage the real performance boost: Caching! Let me explain a few words first how WordPress works. Don’t worry – you do not have to become a programmer 😉
What WordPress does while you wait for a page to load
WordPress like any other Web application consists of php-files, css-styling files and a mysql- database. The php-files usually contain the “logic” of the theme or plugins you are using. CSS (cascading style sheets) hold the code for the design of your site. And finally the mysql (or mariadb) database contain the content of your pages and posts along with many settings your WordPress installation needs to store – like the domain name or the paths of your URLs.
A simple click of a surfer on your WordPress page will most likely run as follows:
- A WordPress php-file is loaded and it starts executing. If it finds another php-file that is required to be started it will execute the second php-file and so on until it reaches the end of this chain
- If there is a need for data from the mysql database additional code is executed to query the database and present the results (the content of a post for instance)
- Finally all this produces html-code that your browser can read and render in order to show a visual result to the visitor.
In most cases all this will take just a second or two. But what happens if different visitors click on the same webpage over and over again? The aforementioned process is repeated over and over again. The result of this repeated process is the same in most cases.
How a caching mechanism works
This is where caching comes in: Instead of repeating the multistep process of executing php and producing over and over again the HTML-result is stored for a defined amount of time (usually minutes or hours) as a so called static html file.
This final static html result is then presented to the second, third, fourth (and so on) visitor which results in faster load time for everyone after the first visitor.
Best practices for caching plugins:
Most caching plugins do NOT cache when you are logged in to WordPress installation and that’s perfectly ok. As long as you are writing content, modify your WordPress admin area or simply do styling changes you need to see the result of your change right away. Caching would not make much sense here.
Therefore: As long as you write content, change settings or modify your site in any way you’d want to do this in one browser session – for example in Firefox. If you want to see the results of your change as a user or visitor, use your second best browser (I use Chrome for it) and have a look at your own website like a normal visitor would without being logged in.
Doing major modification on your website with a caching plugin turned on will cause you headaches – promised.
Tipp: Turn your caching plugin off as long as you do major changes in your theme or plugin settings. As soon as the settings fit your needs, save them and turn on the caching again. Then head over to your second browser and click through your site and check the results
The best caching plugins to speed up WordPress
Now that you understand the basics of what the caching mechanism does, let’s have a look of at the most common caching plugins:
W3 total cache
W3 Total Cache is one of the major caching plugins you can find on WordPress.org. Although there is also a paid version the base version of the caching plugin is free to use.
The plugin covers almost every aspect of caching and performance for WordPress. As a WordPress beginner you might easily get confused with the feature-heavy admin panel.
My personal experience with W3 Total Cache is somewhat mixed. In some cases it worked well and did what it was supposed to do. In other cases it caused me endless headaches … the last time I personally used it I went over to wp-rocket and tried their solution.
Wp-rocket is a premium WordPress plugin. It’s offered for 39 US-$ (for a single site license)
Like the other caching plugins wp-rocket needs to modify the following files /folders
- wp-config.php – it adds the statement “define( ‘WP_CACHE’, true );
- underneath the wp-content/cache directory it adds its own folder where it needs to have write permissions (usually 775 or 777)
Don’t worry: As soon as you activate wp-rocket you will be shown with hints and actions if you are required to change any of the settings above. If you do not see any warning wp-rocket will be simply ready to work for you.
Note: We own an agency license for unlimited sites and use wp-rocket on most of our own and client sites. We have found wp-rocket to be most reliable among the commercial caching plugins. It is updated on a regular basis and it is really great for larger websites especially sites with a huge amount of plugins and woocommerce installations.
Besides that we want to have 3rd level support by the developer in case we need it.
WordPress Cache Enabler (free)
WordPress cache enabler is a very lightweight caching and effective plugin. In my opinion is is a very much overlooked caching plugin. It is developed by KeyCDN whose main product is a CDN but it works well without their CDN.
Unlike W3 Total Cache, WP Super Cache or wp-rocket “Cache-Enabler” has only a few settings and most important: it works right out of the box if you follow these instructions:
Before you begin installing cache-enabler please make sure your wp-config.php and .htaccess file within your WordPress installation are writeable by the webserver. Also the wp-content directory should have permission 755 or 775 .
Install the cache-enabler plugin as you would with any other plugin and activate it. Head over to the plugins settings page and change the cache expiration time to fit your needs. I usually set it to 48 hours or even 72 hours which is a good starting point.
Make sure to check the following:
- Open your wp-config.php file and search for
Tip: In our very own performance tests we challenged wp-rocket and cache-enabler. Cache-enabler clearly won the battle over wp-rocket.
In my opinion the “Cache-Enabler” Plugin is the best fit for any beginner who wants to speed up WordPress without the hassle of a huge and clunky monster plugin.
More options to speed up your WordPress site
Without going into too many details, there are a few more things to consider if you really want to speed up your WordPress installation for maximum performance:
Shrink your images
Images and other visual elements are pretty much important for your visitors experience. Unfortunately large photos usually are also large in size. Try to minimize the size of your images by using a program like Caesium or an image optimizer service like http://www.reduceimages.com/ , http://www.picresize.com/ .or http://www.imageoptimizer.net/Pages/Home.aspx
Most image resizer services or programs will reduce the size of your images down to 10% of the original file without any visual loss.
The same applies to image size in pixels: If your site is 1200 pixels wide it is usually unnecessary to upload images that are larger than 1200px. Since most cameras on smartphones have full HD or 4K cameras their image size and quality are way too high for your website.
As long as you are not an artist or a photographer you should consider reducing file size of your images.
Pro Tip: If you have lots of images in your wp-content/uploads folder you may simplay download the image files, shrink them locally using Caesium and upload them again. Make sure the file-names remain the same.
Reduce your attachments – PDF
As with photos the same applies to any other file you ever uploaded to your WordPress blog. If you are offering a free Ebook or a lead magnet as PDF-file you may check its size and consider shrinking it.
Change your WordPress theme?
According to P3-profiler the theme accounts for at least a second of processing time. Larger themes take even longer than WordPress itself to process. Please check the P3-profiler results of your site to make sure you are not over-engineering your plugins if you should consider changing your WordPress theme.
Themes that are loaded with lots of features usually come with a lot of php-code to process which then results in slower loading times. So be careful – sometimes a “smaller” theme might be a better fit for you and your readers.
There is quite a bit of work to be done to speed up your WordPress blog. Take your time and do your homework with baselining, checking plugins and leveraging caching by using a WordPress caching plugin like cache-enabler.
What are your experiences with WordPress and performance? Leave a comment below and let me know.
- Remove line breaks and paragraphs from Contact Form 7 - 26. April 2017
- New Themes & Plugins for WordPress - 25. April 2017
- Envato: Latest Themes for WordPress (Week 15 / 2017) - 18. April 2017
- Speed Up WordPress - 17. April 2017
- Best Testimonial Plugin for WordPress - 16. April 2017