As you probably know the website speed impacts the search ranking. So, the faster your website loads, the better it will be for search for your site’ Search Engine Optimization (SEO).
There’s a page speed test tool by Google which allows you to test the loading speed of your website:
https://developers.google.com/speed/pagespeed/insights/
The tool is very useful and it also generate suggestions for improvements that you can apply in order to improve the page speed. One of the suggestions you probably will see for your WordPress site are:
- Leverage browser caching
- Enable compression
The good news is that you can easily implement the above suggestions. Here are all of the necessary steps:
1. Access your WordPress root folder with an FTP client such as FileZilla or FireFTP Extension tool for Firefox browser.
2. Download and open the your_site_folder/.htaccess file with a text editor i.e. Notepad
3. Add the following code to the end of the file:
Header unset Pragma
FileETag None
Header unset ETag
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
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 text/html “access 1 month”
ExpiresByType application/pdf “access 1 month”
ExpiresByType text/x-javascript “access 1 month”
ExpiresByType application/x-shockwave-flash “access 1 month”
ExpiresByType image/x-icon “access 1 year”
ExpiresDefault “access 1 month”
</IfModule>
## EXPIRES CACHING ##
<FilesMatch “\\.(js|css|html|htm|php|xml)$”>
SetOutputFilter DEFLATE
</FilesMatch>
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
4. Save changes an re-upload the .htaccess file
And that’s really all. Applying of the above will increase dramatically the page speed of your WordPress site.
Here are the results BEFORE applying the above steps:
And here are the results AFTER applying the above steps:
As you can see, the Speed for Mobile is now 68 (before: 54) and for desktop it’s 86 (before: 67). So, it definitely worth the efforts for applying the above steps.
Thank you Tihomir for the post. This tutorial helped me to fix leverage Browser Caching. Besides, I improved my site performance a lot. My current speed test result is 80.
Regards, Jyoti