Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • .htaccess: How to do Apache gzip compression?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 255
    Comment on it

    I am writing this blog, which will provide you help to compress files with the help of .htaccess file.

    When Gzip Compression is enabled on your web server then it will make the file sizes smaller. This will  load your website faster. When a request is made for a page from your site by a browser, your webserver will return the smaller compressed file. All modern browsers understands compressed files.

     

    Enable compression via .htaccess

     

    Compression is made by adding few lines of code to a file called .htaccess . Please add the following code to enable gzip compression.
     

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

    This file will compress following files with extensions: .html, txt, css, js, php, pl, text, all images.

    Now save and upload the file to the root directory of .htaccess and refresh the website. It will load faster than before.

    Thanks for reading the blog

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: