Improve a WordPress website Page Speed by 50% in 5 minutes

07 July, 2013 by Tom Elliott

OK, so you have a WordPress website and FTP access? Great! Here’s a quick guide on how you can vastly improve your Google Page Speed score in just a few minutes.

The 5 minute page speed improvement guide.

Step 1 – Caching plugin

The plugin W3 Total Cache will cache and compress a load of files to reduce page download time.

  1. Log into WordPress as admin
  2. Plugins -> Add New -> Search ‘total cache’ -> Install ‘W3 Total Cache’
  3. Plugins -> Activate W3 Total Cache
  4. Under the new ‘Performance’ menu -> General Settings -> Select the following:
    1. Enable ‘Page cache’
    2. Enable ‘Minifiy’ (keep default settings)
    3. Enable ‘Browser cache’
  5. Click any ‘save all settings’ button
  6. Select ‘Empty the page cache’ notification if it appears at the top of the page
  7. Double check your WordPress site/blog to make sure everything is working

Step 2 – .htaccess modication (Apache server only)

Modifying the .htaccess file to tell the browser to cache and compress various files to reduce server load and improve page speed performance.

  1. FTP Download the .htaccess file from the root of your WordPress site
  2. Open the .htaccess file using your favourite text editor
  3. Copy and paste the below code at the end of the file and re-upload
##### EXPIRE CACHING - LEVERAGE BROWSER CACHING #####

# Enable expirations
ExpiresActive On

# Set default expire time
ExpiresDefault "access 2 week"

# Specify expire time by file type
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType image/x-icon "access 1 month"

## END EXPIRE CACHING ##

That’s it, all done – double check your site to make sure everything is working. Head over to Google PageSpeed Insights and enter your website address to get your Page Speed score.

Further page speed notes

How fast your website loads is increasingly important. People expect sites to load quickly, we have less patience and if a website hasn’t loaded within 2 seconds, your website visitors will become frustrated and go elsewhere before they have even seen your content. Furthermore, Google now uses page speed as a ranking factor and it’s fair to assume that a website’s load time will become increasingly important as internet speeds increase along with our expectations. It sort of makes sense. Google wants to (and has always wanted to) return the most useful results in the SERPS and sites that are constantly slow are of little use.

WordPress drives nearly 20% of the web. This is a phenomenal amount and many degrees higher than any other content management system. Yet most WordPress website owners probably aren’t aware of some of the tools available to help increase WordPress site speeds and page speed scores.

When I tried these techniques out on a new site with a custom built theme, my Google PageSpeed score increased from 39% to 95%, an increase of over 50%!

W3 total cache

The W3 total cache plugin has a number of features that can help improve page speed but I think the following aspects are the most important:

Page cache
Page caching basically saves each page on your WordPress website or blog as a regular .html file on your server. This will be served to the visitor directly rather requiring the database to generate the pages each time they are visited.

Minifying
The process of minifying greatly condenses your CSS, JavaScript and HTML pages into smaller file sizes by using a number of techniques such as removing white space, removing comments and renaming functions and variables. If you look at a minified JavaScript page for example, you’ll see a big block of code on one line that is virtually impossible to decipher. This is because all function and variable names for example are replaced by single characters. *I used to think clever JS programmers coded like this directly*

Browser cache
Browser caching allows web browsers to save files on the visitors local hard drive which increases page load time and decreases server load as files don’t have to be downloaded repeatedly.

Other caching options
There are also other caching features including database and object caching. These will cache common database operations to further reduce server load time. I often don’t like to enable these functions however as there can be a huge number of database operations going on which can create thousands of files and folders on your server. For users with shared or VPS hosting packages especially, this can use up disk space or use up ‘inode’ resources.

.htaccess modification.

If you’ve ever seen the suggestion ‘leverage browser caching’ when using Google Page Speed Insights, this .htaccess modification does just that. It basically tells the browser to cache certain file types and gives default expiry time for when the browser should re-check the files. This will only work on Apache web server set-ups however using module mod_expires.c, which should be enabled by default on most Apache setups.

The first part of the .htaccess modification adds a line to check if mod_expires.c is present and if it is, activates the expirations with the command ExpiresActive On. Then we can set a default expire time for all files and then specific expiry times for each file type. For example, I will rarely update existing images, so they are given a longer expiry time of 1 month.

Setting up both the caching plugin and .htaccess modification for improved page speeds is best done once a site is live. During development, there can be many frequent updates and you won’t want to empty the W3 plugin cache and browser cache each time you make an update.

Additional Page Speed improvements

There are many additional techniques that you can also implement to increase your WordPress site’s page speed but with this post I’ve focused on a couple of ‘easy wins’ – the actions that take the shortest amount of time but give the highest page speed improvements – caching and .htaccess modification. Other improvements include things like optimising images (both compression and size), optimising the WordPress database and increasing server response speeds – VPS or Dedicated servers for example usually have higher speeds and better page speed scores over shared hosting solutions.

Disclaimer: Please note that results will vary, page speed scores are highly dependant on many things including server response time and image optimisations.



19 ways to improve the speed of your WordPress website »
Automatically optimise WordPress images for maximum compression »
WordPress website slow? Time to optimise your database »
10 advantages of developing bespoke WordPress themes »


45 Comments

  • This took my page speed rank from 30 to 70 literally in five minutes 🙂 Thank you!

  • Ashley says:

    Thanks for posting this. I’ve been looking for plugins like this for a while and this seems to be a good one for increasing page load time.

  • Diana says:

    I did the changes that you mentioned and also added the Smush.it plugin to reduce my image sizes and my page speed has greatly improved. Thank you for the tips!

  • Great! Thanks a lot.
    Just a thing: “*I used to think clever JS programmers coded like this directly*”… no, actually no, because it would make it much more complicated to maintain and debug a piece of programming code if all your variables are named a, b, c… Imagine trying to plan a trip to a country if all the cities are named a, b, c … 😉

  • Greg says:

    Hi Tom,

    I have been trying to find a way to leverage browser caches for pages? When you used the code and put it in the htaccess file it works only for the homepage which my is 90 for desktop. However, most users are going to pages and not the home page. So, how would you speed up a page? My pages are only 83 or so. Any insight would be helpful.

    • Tom Elliott says:

      Hey Greg, when you drop the .htaccess file to the root of your site, it should affect all sub folders of your site (and therefore sub pages), unless you’ve got separate .htaccess files in sub-folders. It could also be that your sub pages have elements or file types that aren’t specified in the .htaccess or there’s other optimisation issues? Hopefully comparisons within Google PageSpeed and drilling down through the details will help shed some light on this 🙂

  • Muj says:

    Hi Tom,

    I tried this it looks like it has worked but sometimes it does feel slow i have checked it and this is the result http://tools.pingdom.com/fpt/#!/el8Cq2/www.tobangladesh.co.uk can you advise further maybe?

    • Tom Elliott says:

      Hey Muj, yeah – looks like browser caching and minifying is largely in place and producing quite good page speed scores but the slowness of your site will (almost certainly) be down to your web hosting package. Running a couple of Page Speed tests came back with response times between 2 and 3 seconds and will reduce your page speed score. Obviously speeds between hosts vary but moving from shared hosting (if that’s what you’re using) to either VPS or dedicated server hosting will provide the biggest boost to website page speed.

  • Akhil says:

    Excellent tips. Thanks for the useful ideas. What is your opinion, W3Total cache or super cache is best?

    • Tom Elliott says:

      Hi Akhil, thanks – To be honest I haven’t used super cache so I can’t really provide a good comparison. From what I’ve seen, they are both highly rated cache plugins that can help with page speed but W3Total seems to have more features.

  • VirusGuy says:

    great tips. we just switched from w3 to supercache. we used w3 for over a year and there were constant bugs and we spent a ton of time administering it, reinstalling, resetting, etc. we switched to supercache and its rock solid, never have to touch it.

  • Honey Singh says:

    Excellent guide Tom, I had employed each and every step you had mentioned here, on my site. Yes! I was able to reduce the loading elements and overall load time but, unfortunately it seems the response time of my server is ridiculously high.

    I am on shared plan, do you think switching to a VPS will effectively sort-out this issue?

    Thanks!

    • Tom Elliott says:

      Thanks Honey. Yeah, shared hosting will usually be one of the biggest factors behind slow response times… I noticed much better response speeds when I moved from shared to VPS 🙂

  • medialup says:

    @Honey Singh it’s not necessary switching to a VPS, you could just search for a better hosting provider and still use a shared plan.

  • Mike says:

    Thx for this but stil no fixed result dont know wat is going wrong
    in the Leverage browsing caching it stays bad allot of files stay at 1 day :S
    do u got some more tips? ty

  • Matt Keys says:

    I made a Google Pagespeed Insights plugin for WordPress. It is a great tool for people who are looking to further improve their sites performance based on pagespeed recommendations.

    My plugin runs and stores pagespeed reports on all of your WordPress pages, which allows you to visualize your highest and lowest performing pages. You can also view report summaries to see the ‘big picture’ of your sites performance. Summaries show the biggest areas for improvement across all reports.

    The free version is available on the WordPress Codex: http://wordpress.org/plugins/google-pagespeed-insights/

    My website includes additional plugin information and videos, as well as the premium plugin and features: http://mattkeys.me/products/google-pagespeed-insights/

  • Alejandro Maisonnat says:

    Depend everytime from plugin..

  • Ryan says:

    Thanks for this.

    Moved my page speed number from 79 to 87 with just the .htaccess additions. Tried W3, but it was caching a shopping cart widget as well. Will have to dig a bit more on that, but for now I’m really happy with the improvements from setting expiration headers.

  • Chetan says:

    Nice post this took my page speed rank from 80 to 90 literally in five minutes 🙂 Thank you!

  • Donna B. says:

    This seems to work! Thank you so much! I had the plugin, but never the leverage code.

    Interesting how Mobile tab now appears before Desktop – proving that Mobile is their new sainted son. With Mobile, but not Desktop results, it suggests that even more leveraging would be helpful, like this one: http://pagead2.googlesyndication.com/pagead/osd.js (60 minutes)

    Can I just write it like you did?

    ExpiresByType pagead2.googlesyndication.com/pagead/osd.js “access 60 minutes”

    Would this be correct?

    • Tom Elliott says:

      Hi Donna, yes it’s a good point. The browser cache leveraging via .htaccess will only affect files on your domain rather than externally hosted resources. I had the same issue with some ad code from a 3rd party as well, but the 3rd party eventually implemented the caching at their end.

  • alan says:

    took my page speed from 91 to 93,after that .htaccess modification
    thanks TOM 🙂

  • rakesh kumar says:

    But lots of people are not able to optimize their websites besides the best tutorials, for all those people, i Have developed a wordpress theme named – pagespeed, that is able to score 97 with all the plugins and widgets. Hope you would love to mention that theme in this article.

  • My page speed number got to 80 – 85 from 60 – 65 by adjustments suggested in this post.
    Thanks for sharing such a fantastic post. 🙂

  • I think one of the quickest ways , is we added maxcdn as our cdn provider. It has taken our site to new levels. I am around 85 speed score now.

  • Lawal A says:

    Nice tips, will try them all. Thank you

  • Dilan says:

    Hey Tom,

    After activating W3 Total Cache, my h1, h2, h3 & Meta Keywords got lost ….. (used seoworkers.c om/ to check the site performance. that’s where i realised about the problem)

    Any advise on this?

    • Tom Elliott says:

      Hi Dilan, that sounds odd.. do they vanish from the HTML completely or is the styling hiding them? If this content is being driven by JavaScript (probably shouldn’t be the case anyway) perhaps the JS is causing a conflict. I’d also try disabling other plugins (which may also be causing a conflict) or enabling each of the W3C checkboxes one by one to try and narrow down the cause.

  • Danila says:

    One can use http://www.getpagespeed.com service and automatically optimize the whole server for speed so that all websites make use of gzip compression, html minification and php opcode caching! 🙂 It’s almost free compared to hiring freelancers or wasting your on time to manually do optimization tricks

  • Holger says:

    Thank you very much for sharing this.

    I followed your instructions and my google pagespeed went from 65/100 to 100/100!!! in a few minutes!

    Thanks a lot!

    /H

  • Laura says:

    Hi,

    I don’t have a .htpaccess file but iirf.ini. Is it possible to modify this document as well?

  • umashankar says:

    Works like a charm!

  • Ejvind says:

    Good article. I improved the page rank from 64 to 81. Not as much as I had hoped, but now I am ready to study some more 🙂

  • Gode Toner says:

    This really helped me with both my WordPress blog and my Magento webshop. In desktop google page speed our ink cartridge webshop went from score 54 to 72 after just 30 minutes of work.. Niiiice 🙂

    I would recommend the w3 total cache for any wordpress blog. It really helps and is super easy to setup and use.

  • Saba Pervaiz says:

    it took my website speed up , this is really useful, thank you for sharing.

  • Reinardt says:

    All of the suggestions did definitely help with page speeds, just thought it would be more. But it might be the theme I am using, so the hunt is still on for increasing speed. W3 Total Cache does increase your site speed more than other plugins I have tested. Keep up the good work guys.

  • MMuse Hassan says:

    VIOLA! Yes, it improved to 71%.

  • Daniel Keith says:

    Hi there,
    Nice post. I thought that W3 total cache would be the best solutions to decrease my website’s load time. But everything went opposite.
    Before installing it my website’s load time was 7.59s which has now reached to 8.31s. Any idea what happened wrong?

  • Many thanks for this and two other articles on the best WP plug-ins. I’ve had loading speed issues reported all over my site had no idea all my updating of posts was clogging the drains and was surprised at how much my media library images could be reduced. And on top of all that you’re bringing me new leads with the pop up registration.

  • Bright Joe says:

    Woo! Must thank you for this. I had been seeing my site loading site decreasing gradually, but after the .htaccess modification, it’s back to a good loading speed!

    Thanks a lot! 🙂

  • Sakshi says:

    I have followed all its tactics to improve my blog performance. Really it work 100%. I have tested my blog in gtmetrix[dot]com before (applying this trick) this show Pagespeed score 82% but now after applying these increasing process, Show Pagespeed score 92%.

    I can’t belief this. This is really true or bypass the checking speed.

    Really Thanks dude..!!

  • Sasha says:

    Hello,
    Tom.
    Thank you for your tutorial.
    But i have a problem with making what you suggested here. My site now lost all functionality.
    I tried to rewrite back the .htaccess file back without the code but the website know looks like this http://levslutsky.com/
    I deleted the file but still the same.
    I’m really confused about it. Maybee you can suggest me some solution?

  • Nick Danks says:

    Looks like im getting a white page when activated? Suggestions?

  • Aaryavarta says:

    Hey Tom,
    Thank you for your good article.
    you write code in that article is good and working,
    i put that code in .htaccess file and back to check it and realy its working….

  • Leave a Reply

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

    css.php