How to activate gzip compression for better client performance (mod_deflate)


Using gzip, the Apache webserver module mod_deflate / mod_gzip allows HTML and CSS files to be compressed, reducing the size of transferred files by up to 70%. This results in shorter loading times for your website.
Especially for visitors accessing your website with relatively slow connections (using their smartphones for example), the compression can lead to a noticeably better client performance.

Activating gzip / mod_deflate compression

You can activate gzip compression by adding an entry to the .htaccess file on your webspace.

  1. Access your webspace via SFTP and open the .htaccess file with a text editor (such as Notepad++).
  2. Paste the following code at the end of the .htcaccess file.
    Activates compression only for specific MIME types (learn more about MIME types):

    <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
  3. Save the .htcaccess file and upload it to your webspace:
    The edits to the .htcaccess file apply to the storage directory and its subdirectories respectively.

Testing gzip / mod_deflate compression

You can test the gzip / mod_deflate compression with Google PageSpeed Insights for example. You can also use the developer tools of your browser (Chrome or Firefox for example) to display the content-encoding information for your website.
Open your website with the browser of your choice, activate developer tools and switch to the Header tab. Look for Content-Encoding: gzip.

Please note: A small number of webhosting packages might need additional adjustments to enable gzip. If you need help enabling gzip, please contact our support team.

You might also be interested in

Activate 1&1 CDN for a Domain (1&1 Help Center)


Please rate this post :

29 thoughts on “How to activate gzip compression for better client performance (mod_deflate)

  1. Daris says:

    Hi, QQ(I hope). I tried using the above tip for shared hosting:

    php_flag zlib.output_compression on
    php_flag zlib.output_compression_level 5

    However when I add that to my .htaccess file I get a server 500 error. I’m using php 5.6… Anything else I can try?

    1. Philipp Bellmann says:

      Hey Daris,
      we are currently working on a solution and I will update here as soon as possible. My apologies.

      1. Daris says:

        Hi… Any updates on this? I’m Really looking forward to being to able to use gzip / compression on shared sites.

        1. Gg says:

          Hi, I saw your suggestion and I had the same problem so I saw a line added in .htaccess: AddHandler x-mapp-php5.5 .php .html .htm .js – well it worked out but I had in php.ini: zlib.output_compression = On and zlib.output_compression_level = 9 and allow_url_fopen = On . Well the AddHandler is a must and the others I think too, try and tell us

  2. BKToh says:


    I copied and pasted the code to the .htaccess file, did a test and the result says Gzip is not enabled. Please help.


  3. Ed Kiefer says:

    I did the same. Copied and pasted the code into my .htaccess file and sames results. Gzip is not enabled. Why?

  4. Mike Saeger says:

    I just talked to Technical Support on the phone about this. In their shared hosting environment, the .htaccess file cannot turn on compression. She said she is sending me information on ZLID which can enable compression via PHP. I’m waiting for the information.

  5. Mike Saeger says:

    Make that ZLIB compression. Here is the link she sent me:

  6. Mike Saeger says:

    So after reading the info on ZLIB, all you have to do it add the following to the top of your PHP application:

    Everyone one of my PHP programs now show that they are Gzipped.

  7. Mike Saeger says:


  8. Thanks Mike for this information!
    But I did not understand where to add this code 🙁

    Can you give us more details on how to do it (which *.php, etc …)?

    Thanks a lot by advance!

  9. jon says:

    So this post is completely useless because 1and1 does NOT run mod_deflate.c on Apache. Kind of senseless as PHP compression stands to use more CPU and not enabling mod_deflate.c increases bandwidth usage.

    I guess we will never know what engineer thought this to be smart.

    1. 1and1help says:

      Hi jon,

      quoting the article:

      “Please note: A small number of webhosting packages might need additional adjustments to enable gzip [mod_deflate]. If you need help enabling gzip, please contact our support team.”

      Please send us an e-mail to with your customer id, referring to this article. Then we will do the additional adjustments for you on our server and you can use mod_deflate in the future. 🙂

      Thanks and best,
      Michael, 1&1

      1. Mr Mistry says:


        I’ve emailed 1&1 on the address you gave above including all the information you had asked for and I haven’t heard anything? Also I opted to call 1&1 support and they said they do not support GZip and they didn’t know what mod_deflate was!

        What can I do?


        Mr Mistry

        1. 1and1help says:

          Hi Mr Mistry,

          we received your e-mail and will reach out to you asap.

          Thanks and kind regards,
          Michael, 1&1

  10. Interested to find out what the answer to Mr Misty was above. Can someone share it here?

    1. 1and1help says:

      Hi Sam,

      I think we sorted this out with our customer. 🙂 May I ask you where your question is coming from? As I can see by the domain name you added to your comment, mod_deflate is already supported on the webserver your account is located at.

      Best regards,
      Michael, 1&1

  11. Ben Hayes says:

    I am looking to enable support for gzip on my site too. I believe I fall into the category of the “small number of webhosting packages might need additional adjustments to enable gzip [mod_deflate].”

    1. 1and1help says:

      Hi Ben,

      just send us an e-mail with your account data to and we’re happy to activate mod_deflate for your webspace.

      Best regards,
      Michael, 1&1

  12. Jon says:

    I added the Mod_Deflate to my htaccess but when I check it using Googles page speed insights it says that it has not been compressed. What do I need to do?

    1. 1and1help says:

      Hi Jon,

      I tested this with an example .htaccess stored on your webspace and mod_deflate works like a charm. Look at the results here:

      Best regards,
      Michael, 1&1

  13. Hi,
    Can we increase the bandwidh of website,

    1. 1and1help says:

      Hi Jeena,

      I am not sure what you mean by that.

      What is the issue?

      Michael, 1&1

  14. Sarah Cowan says:

    Hi there

    I also need mod_deflate activated please. I have sent an email to

    1. 1and1help says:

      Hi Sarah,

      we will take care of it for you. The activation can take up to 2-3 business days. We will inform you via e-mail as soon as the activation is done.

      Best regards,
      Michael, 1&1

  15. Jamin Rak says:

    I also need mod_deflate activated on both my desktop and mobile versions please. Gzip is having issues.

    Gzip is not working properly:

    – Your server may not have the “deflate” module enabled (mod_deflate for Apache, ngx_http_gzip_module for NGINX).
    – Contact your host. If deflate is enabled, ask why all .htaccess or nginx.conf compression rules are not being applied.

    1. 1and1help says:

      Hi Jamin,

      we are happy to assist you on that point. Please send us your customer data and your request via e-mail to

      Michael, 1&1

  16. Patric says:


    I have requested gzip to be enabled on mysite but what do I update my .htaccess file with?

    1. 1and1help says:

      Hi Patric,

      with the code you see in step 2 of this article.

      Best regards,
      Michael, 1&1

Leave a Reply

Your email address will not be published. Required fields are marked *