How to enable browser caching & gzip compression on Apache webserver

How to enable browser caching & gzip compression on Apache webserver

Page speed is vital for SEO. The faster your website or web page loads, the better chance of it having better position in the search results. To measure and get guideline on what to be done to get faster website, you can use online tools like Google PageSpeed Insights, GTMetrix or WebPagetest.

Each tool will probably give you a handful of suggestions in how to improve your site’s speed. However there are 2 most essential components that you need to be sure have been implemented on your website or server. They take only a few minutes to set up but give the most noticeable impact to the site’s performance.

If you are using Apache webserver, below are the instructions to add them.

Enable browser caching

Add this into your .htaccess file:

Enable gzip compression

Add this into your .htaccess file:

Sometimes due to the server’s configuration, the gzip compression works on every other file except CSS and JS files. If this happens, you could try adding this before the ## ADD GZIP COMPRESSION ##:

 

That’s it. Give the site another test on page speed tools and see how much the score has improved.

Leave a Reply