GET YOUR GOOGLE SPEED CODE!

Here is code provided directly to us by Google’s page speed engineers specifically for your website’s .htaccess file to speed up your site and increase your Google Page Speed score!

While there are plenty of blogs out there talking about speeding up your site with your htaccess file, this information came DIRECT from Google’s own page speed team, so it doesn’t get any more accurate than this when it comes to “what Google wants” and when we implemented this script we noticed a significant difference.

What Does The Code Do?

While there are many ways to speed up your site one of the easiest is to simply make sure you have the right settings in your website’s .htaccess file. It is a file that manages server settings as they relate to your website. Making some simple changes to this file can significantly increase your website’s speed.

What is the .htaccess file?

  • 1. The .htaccess file is a hidden file located in the root (usually the public_html folder) of your website.
  • 2. When we say it is hidden we mean that files starting with only a dot often do now show up without enabling their view. If you don’t see it in your file explorer or FTP program, generally you would click VIEW and then choose something like “SHOW HIDDEN FILES”.
  • 3. The .htaccess file controls various settings for your server as it relates to your website like page redirects, caching and file compression.
  • 4. To speed up your page the code below specifically alters the compression of your website assets and the caching of those assets by your user’s browsers.

IMPORTANT!

Make sure you backup your .htaccess file before making any changes. INCORRECTLY ALTERING YOUR HTACCESS FILE CAN CAUSE YOUR SITE TO STOP WORKING. ALWAYS MAKE A BACKUP.

Use the script below AT YOUR OWN RISK. We will not be held responsible for any issues using this script may cause.

In other words… Make a backup. If you have any trouble, put the backup code back and you will be fine and dandy.

THE CODE

Below you will find the settings/code sent by Google to speed up your website. Simply add this to your htaccess file (per the instructions above) and then run another speed test to see if it helped your site gain any speed or not.

Any questions, please let us know. We would love to help. Just post in the comments below.

 


<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</IfModule>

# Leverage Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
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>

<IfModule mod_headers.c>
<filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
Header set Cache-Control "max-age=2678400, public"
</filesmatch>
<filesmatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, private, must-revalidate"
</filesmatch>
<filesmatch "\.(pdf)$">
Header set Cache-Control "max-age=86400, public"
</filesmatch>
<filesmatch "\.(js)$">
Header set Cache-Control "max-age=2678400, private"
</filesmatch>
</IfModule>

 

Leave a Reply

Close
Go top