Improving page speed  can help any web site with better SEO results and more user visits on average, and there are many ways to help achieve those faster load times. Some of these methods can be easily fixable while only requiring you to edit your .htaccess file found on your website’s server.

The best speed options that can be done through .htaccess are leveraging browser caching and enabling compression.

Leveraging Browser Caching

Caching will help your browser remember certain resources or items in order to load a page easier. If caching rules are not set then a browser will have to look for those resources each time a page is loaded. In your .htaccess file, the following block of code will help your browser understand which files to cache and for how long until that information is cleared. Please take note that while the cache times are pretty optimized for the associated formats, you can make changes if you wish (“1 year” can become “1 month”, for example).


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"


Enabling Compression

Gzip compression for wordpress sites is a common practice to help compress many files and resources in order for them to be delivered much faster across a network. Alterior methods exist for multiple server types, but the .htaccess method is our recommended approach for all wordpress sites. In order to ensure your server can gzip all file types, use the following block of code in .htaccess. Note that if you are having issues with gzip compression then you may need to look at your webserver configuration and see if compression is allowed/enabled.

    <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.*

With browser caching and file compression in place, you should already see an improvement when you next check your page speed results. If you still have questions regarding .htaccess file editing or any other page speed concerns, contact us at any time!