In this tutorial we are going to talk about how to improve page load speed using htaccess gzip and cache tricks, We all know htaccess is a very powerful file in apache server which control your website behavior, This file is useful in many cases like creating user friendly SEO url’s , Removing extension (.php, .html) or setting your custom extension name So using htaccess you can control your website like boss. Here I am going to show you how you can easily improve your website performance, page load speed, optimize pages and make your website load faster.
Step-1: mod_gzip is an Apache extension that allows to quickly and easily compress web files before send them to the client. This boost your website page load speed.
If your website on shared hosting then compression tool already available on your control panel and you just have to enable it.
1. Goto your control panel and you’ll see option like Optimize Website, click on it
2. After that enable compression of all content and update setting.
Step-2: You must use cache control for your website like if first time visitor comes on your website it load whole content of website like JS, CSS, Images, But if you apply cache control for your website it makes easy to load website content faster for returning visitor, and they get better user experience.
Finally set cache control headers.
<ifModule mod_headers.c> <filesMatch "\.(ico|jpe?g|png|gif|swf)$"> Header set Cache-Control "public" </filesMatch> <filesMatch "\.(css)$"> Header set Cache-Control "public" </filesMatch> <filesMatch "\.(js)$"> Header set Cache-Control "private" </filesMatch> <filesMatch "\.(x?html?|php)$"> Header set Cache-Control "private, must-revalidate" </filesMatch> </ifModule>
I hope this htaccess trick will make your website faster and smoother.