How to enable browser cache and gzip compression to htaccess

Enable browser cache and gzip compression to htaccess

Now we are going to learn how to create browser caching in .htaccess file, here in the below code we are simply adding the type of the file needs to be cached,you all think why we need to add this type? simple when a user access particular web page which loads very fastly in most website,it’s all because browser caching instead of loading each and every image and filetypes like css,js and videos we can add all these types in caching to increase website load performance.

In below code we are adding expires time to each and every type we added in the above code,here A31536000 indicates A for Access and numeric code indicate time for expire, and also we can add as below.
ExpiresByType text/css “access 1 month”
In the above code we can change the expire time 1 month by replacing “Month” to “Year”.

READ  Integrate CKeditor with codeigniter

Here in the below code we are enabling the gzip compression in apache web server.

READ  How to update form using Angularjs and codeigniter?

Here the below code do all the matching files,unset the header cookie.

Thanks for reading this article

READ  How to fetch form data using Angularjs and display in codeigniter view?

Leave a Reply