...

How to Optimise Your WordPress Website for Speed

When it comes to optimising your website, caching can play a big role. Caching can help you reduce the page load and could improve your SEO and conversions just by making your site load faster.

We are going to go for a minimal setup that will get you up and running very quickly. First of all we’ll set up Autoptimize, a WordPress plugin that creates static CSS and JS files, and then we’ll look at the popular WP Super Cache and W3 Total Cache. Depending on your needs and the type of website that you have, you may find one to be more suitable than the other.

W3 TOTAL CACHE VS. WP SUPER CACHE

Depending on your website and how complex it is, you may choose one or the other. But you should never have both installed as this will throw some errors at you.

If you’re running a simple blog or review site, it may be overkill to use W3 Total Cache, in which case WP Super Cache will probably be sufficient to cache your pages and you won’t require any other caching methods. WP Super cache generates static HTML files which are used to serve requests instead of processing all PHP scripts over and over again.

If you are running a high traffic e-commerce store in multiple languages and currencies, and have many dynamic features on your page, then W3 Total Cache may be more suitable for your needs.

W3 Total Cache comes with support for database and object caching as well as allowing you to set up browser and fragment caching, and some great CDN capabilities. If you have a website that utilises multiple queries generating lots of database calls and your database is struggling to cope, W3 Total cache can help with its database caching.

Although it comes with everything but the kitchen sink, the vast amount of configurations available for this plugin does mean that it involves a slightly lengthier setup process.

It goes without saying that you should test, test and test again when it comes to making configurations with these plugins, and see which options suit you the best. Each website and server configuration will have differences and there is no one solution that fits all requirements with regard to optimisation.

SETTING UP AUTOPTIMIZE

Let’s go ahead and install the Autoptimize plugin. Once installed, activate the plugin and navigate to Settings > Autoptimize from your dashboard.

For now you can just check the following options:

  • Optimise HTML
  • Optimise CSS
  • Optimise JS

Auto Optimise

 

These are the basic settings and should be sufficient for the time being. You may have a look at the advanced settings by clicking on the ‘Show advanced settings’ button at the top. Beware: the JavaScript Options settings for this section should not be changed unless you know what you are doing! You can enter your CDN URL here if you are using a CDN for your site and view the number of files generated and where they are stored.

If you have any issues, firstly have a look at the Autoptimize FAQs or go the support forum.

WP SUPER CACHE SETUP

WP Super Cache can be installed through the WordPress dashboard by going to Plugins > Add New. Once installed, navigate to Settings > WP Super Cache for configurations.

The Easy Option

Cache

Select Caching On and you are done!

Advanced Option

Advanced

If you are more adventurous, the Advanced tab has some further settings you can tweak to your liking.

  • Ensure caching is on
  • Use PHP to serve cache files
  • Compress pages so they’re served more quickly to visitors
  • Don’t cache pages for known users
  • Cache rebuild. Serve a supercache file to anonymous users while a new file is being generated

Hit the Update Status button to save your changes.

W3 TOTAL CACHE SETUP

Install W3 Total Cache through the Dashboard in Plugins > Add New.

Navigate to Performance > General Settings.

Enable Page Caching

Page caching will put cached page files on your disk or chosen method and serve this instead of processing all scripts each time. Since we are using the Autoptimize plugin, our page cache will already contain minified code as well our minified and combined CSS/JS files.

Enable Database Cache and Object Cache

Database Cache

If your server has other options installed, then you will see these in the drop-down. In this example we have a separate memcached server running which we will use for database and object caching.

Browser Caching

Browser caching enables your user’s browser to store certain elements of your website and load them from their local cache store instead of requesting them from your server every time.

You can enable the browser cache through your web server if you have access to configure your server. There are different configurations available depending on whether your web server is Apache or Nginx. If you cannot do this, you may use the browser cache configurations below in W3 Total Cache and amend as required.

Enable browser cache in Performance > General Settings.

Browse

Further configurations:

Page Caching

Performance > Page Cache

Cache SSL requests if you are using an SSL Certificate for your website.

Enable Don’t cache pages for logged in users, if your visitors do not have login requirements.

If there are any pages that you do not want caching enabled for, add them into the option below. When running e-commerce websites with page caching, you will need to ensure that your cart/checkout and confirmation pages are excluded from the cache.

Never Cache

Save Settings & Purge Cache

Database Cache

Performance > Database Cache

Ensure the option Don’t cache queries for logged in users is checked.

If you are running woocommerce, you will need to add _wc_session_ to the ignored query stems.

Stems

Save Settings & Purge Cache

Object Cache

Performance > Object Cache

Ensure the option Enable caching for wp-admin requests is turned off

Save Settings & Purge Cache

Browser Cache

Performance > Browser Cache

General browser caching policy:

Browser cache policy for CSS and JavaScript files:

Browser cache policy for all posts and pages including feeds:

HTML

Browser cache policy for all your media items:

Media

Save Settings & Purge Cache

Conclusion

We have gone through setting up just some of the caching options you can use to help optimise your WordPress website for speed. The settings we have used may not be appropriate for all websites, but they are a good starting point and can be tweaked to provide better performance for your web server, database and your visitors.

 

Let us know which caching plugin you are using and share your experiences in the comments below, as well as any questions you have or issues you come across.

2 replies on “How to Optimise Your WordPress Website for Speed”

The article is very informative! I am already using WP SUPER CACHE and it does a good job since the website have few articles.

I have one question : Do i still need to install AUTOPTIMIZE plugin?

Thanks
Sandeep

Hi Sandeep,

Autoptimize plugin creates minified files for your static content. So your HTML CSS and JS will be minified should you choose all three. Minified files have reduced file sizes and delivered to your visitors faster.

WP Super Cache will actually cache your minified HTML too.

Hope this helps.

Leave a Reply

Your email address will not be published. Required fields are marked *