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 plugin W3 Total Cache will cache and compress a load of files to reduce page download time.
Modifying the .htaccess file to tell the browser to cache and compress various files to reduce server load and improve page speed performance.
##### 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.
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%!
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.
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.
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 »
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.
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 … 😉
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.
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?
Excellent tips. Thanks for the useful ideas. What is your opinion, W3Total cache or super cache is best?
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.
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!
@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.
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
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/
Depend everytime from plugin..
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.
Nice post this took my page speed rank from 80 to 90 literally in five minutes 🙂 Thank you!
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?
took my page speed from 91 to 93,after that .htaccess modification
thanks TOM 🙂
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.
Nice tips, will try them all. Thank you
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?
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
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
Hi,
I don’t have a .htpaccess file but iirf.ini. Is it possible to modify this document as well?
Works like a charm!
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 🙂
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.
it took my website speed up , this is really useful, thank you for sharing.
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.
VIOLA! Yes, it improved to 71%.
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.
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! 🙂
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..!!
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?
Looks like im getting a white page when activated? Suggestions?
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….
This took my page speed rank from 30 to 70 literally in five minutes 🙂 Thank you!