Torbjorn Zetterlund

Sat 13 2015
Image

Do you need to speed up your WordPress site speed

by bernt & torsten

So how can you speed up your WordPress site speed? If you install WordPress without speed improvements, your site can become very sluggish, and each page load takes longer to complete. You more traffic you get, the slower your site can be. In this article, I will explain what I did to my site to speed it up.

My article here is more focused on you do it yourself that maintain your server, there is valuable information for all as I touch on some areas, e.g. hosting, that provide all the functionality that I will touch on, so let’s get started. In the next section, I give you some universal tips for speeding up your WordPress site.

Choose a good host

In my case, I went with Digital Ocean, as I will do it all myself – with Digital Ocean, you can fire up a site very quickly, and you have complete control of the server, so you can add tools to the server to speed up site loads. Another good option is Cloudways WordPress hosting, which offers Digital Ocean as one of the server options.

WordPress plugins to speed up your site

In this section, I’m looking at different plugins to help you speed up your site.

1. Start with a solid theme

The default WP themes are quite speedy frameworks to use. When you choose a framework or if you hire a web agency to build one, you can benchmark your new theme against the default WP themes. The principle is the lighter a theme is, the faster it loads.

2. Optimize images (automatically)

Loading images can slow down your website, so you need to think about optimizing your pictures to reduce the file size of an image while not reducing quality. There is a free plugin called WP-SmushIt which will do this process to all of your images automatically. Get WP-SmushIt installed today.

3. Optimize your landing page to load quickly

You need to optimize your landing page. Depending on the type of website, this is the page people will be landing there most often.

Things that you can do include:

  • Show excerpts instead of full posts
  • Reduce the number of posts on the page
  • Remove unnecessary sharing widgets from the home page
  • Keep it minimal!

4. Optimize your WordPress database

Over time your database fills up with spam, unapproved comments, trash posts, etc. Part of running a WordPress site you need to clean up your WordPress database and optimize it without doing manual queries. This can simply be done with the WP-Optimize plugin.

5. Turn off pingbacks and trackbacks

By default, WordPress interacts with other blogs equipped with pingbacks and trackbacks. Every time another blog mentions you, it notifies your site, which in turn updates data on the post. Turning this off will not destroy the backlinks to your site, just the setting that generates a lot of work for your site. For more detail, read this explanation of WordPress Pingbacks, Trackbacks and Linkbacks.

 6. Add LazyLoad to your images

The jQuery Image Lazy Load plugin will not only speed up your page loads, but it can also save bandwidth by loading less data for users who don’t scroll down on your pages.

7. Control the number of post-revisions stored

This is my favourite tip, I tend to click on the Save Drafts button, and each time I do a revision is created, these drafts are stored indefinitely. If you are not doing anything about it. Install the plugin, Revision Control to keep post revisions to a minimum, set it to 2 or 3 so you have something to fall back on in case you make a mistake.

8. Use an effective caching plugin

W3 Total Cache is a great caching plugin, it has all the features you need and is extremely easy to install and use. Simply install and activate your page load faster as elements are cached.

.htaccess file speed up

By editing your .htaccess file, you can gain some page load speed. You can try out the following:

1. Disable hotlinking

Hotlinking is a form of bandwidth “theft.” It occurs when other sites direct link to the images on your site from their articles, making your server load increasingly high. This can add up as your site become more popular.

Place this code in your root .htaccess file:

#disable hotlinking of images with forbidden or custom image option
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?torbjornzetterlund.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]

2. Add an expires header to static resources

An Expires header is a way to specify a time far enough in the future so that the clients (browsers) don’t have to re-fetch any static content (such as CSS files, JavaScript, images, etc.). This way can cut your load time significantly for your regular users.

You need to copy and paste the following code into your root .htaccess file:

ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000

The above numbers are set for a month (in seconds), you can change them as you wish.

Leveraging content delivery network (CDN)

A content delivery network (CDN), takes all the static files you’ve got on your site (CSS, JavaScript, images, etc.) and lets visitors download them as fast as possible by serving the files on servers as close to them as possible.

I use CloudFlare to improve not only the speed but the security of my site. You should try it, and they have a free option that you can start with. I opted for a business plan as it gives me additional security.

Cloudflare, along with the W3 Total Cache plugin, gives you the combination that will significantly improve not only the speed but the security of your site.

Speeding up your server with Varnish + Memcache

If you still find your WordPress site slow after all the suggestions above, you need to try out the Varnish + Memcache combination. This requires you to have a dedicated server to install these two software packages and configure them. You can read the article How to install Varnish + Memcache.

Memcache caches things internally in your application to the server memory. Varnish, on the other hand, stores rendered pages. It talks HTTP, so it will typically talk directly to an HTTP client and deliver pages from its cache whenever a cache hits. When there is a cache miss, it will go and fetch the content from the web server, store it and deliver a copy to the user.

You need Varnish +Memcache as they speed up the delivery of web pages. Varnish speeds up the delivery of its cache hits. When you have a cache miss, the application server might have access to some data in Memcache that will be available to the application faster than what the database is capable of.

If you found this helpful please comment below.

Share: