Enabling GZip on WAMP

Published 09 Apr 2009 in Software by ZigPress

If you use WAMP (www.wampserver.com) to develop websites on a local PC, then you probably don’t need to enable gzip (server-side file compression to reduce the amount of data transferred when a web page is requested).

However, it can still be useful, letting you see how well a page may be compressed by your live web host without having to actually upload it.

Enabling gzip on WAMP is actually quite easy, though most of the advice I found was wrong. Here’s what worked for me.

1. In the WAMP tray applet, enable Apache’s deflate_module and headers_module (letting the service restart each time).

2. In the WAMP tray applet, edit Apache’s httpd.conf and add the following snippet just before the include line at the very end (note: between the ifmodule tags it’s just one line of code – don’t break it):

<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript
</ifmodule>

3. Restart Apache.

Job done!

16 Comments

  1. On 19 May 2009 at 17:45, htpc said:

    where do i insert the code?

  2. On 19 May 2009 at 18:09, Webmaster said:

    After the last ‘/ifmodule’.

  3. On 20 May 2009 at 02:51, htpc said:

    LIKE THIS???

    # Note: The following must must be present to support
    # starting without SSL on platforms with no /dev/random equivalent
    # but a statically compiled-in mod_ssl.
    #
    IfModule ssl_module
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
    /IfModule
    ifmodule mod_deflate.c
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript
    /ifmodule

    Include c:/wamp/alias/*

  4. On 20 May 2009 at 06:38, Webmaster said:

    Yep, that looks OK. I know my blog comment system removes all the angle brackets but I can see where you placed the code.

  5. On 04 Jun 2009 at 15:41, Chainat said:

    This is the article I have been looking for! Good work! Andy!

  6. On 27 Jul 2009 at 09:04, growurl said:

    Dont forget to check PHP setting > zlip output compression

  7. On 05 Oct 2009 at 11:21, Best Bingo Offers said:

    Will this work on XAMPP?

  8. On 22 Oct 2009 at 12:17, Chaussures pas cher said:

    Very good tips. Thanks a lot!

  9. On 10 Sep 2010 at 14:59, Jonas said:

    Is it working on XAMPP?

  10. On 18 Nov 2010 at 11:41, MatTheCat said:

    Deflate is not gzip!

  11. On 30 Jan 2011 at 19:33, Manchester Blog said:

    Just tried to insert the code but failed. Have a feeling might have inserted it in the wrong section. Is it working on XAMPP?

  12. On 21 Feb 2013 at 05:38, Bill said:

    @matt — actually deflate is still gzip, same compression scheme.

    Anyway, I use mod_deflate, tested my output at http://www.gzipcheck.com and confirmed that content is gzipped.

    Works fine for me on xampp, thank you zigpress :)

  13. On 05 Apr 2013 at 12:58, Oisin Conolly said:

    Hi,
    Just tried this with WAMP 2.2 and the services fail to restart with your code snippet.
    I had to change to

    Hope this helps anyone else who encounters this problem.
    Thanks,
    Oisin

  14. On 05 Apr 2013 at 13:01, Oisin Conolly said:

    looks like the comments here don’t allow tags…you need to change
    IFmodule mod_deflate.c
    to
    IFmodule mod_deflate

    in apache’s httpd.conf file

  15. On 21 Sep 2013 at 16:18, suprsidr said:

    Apache did not restart, I was getting ‘Invalid command ‘AddOutputFilterByType’, perhaps misspelled or defined by a module not included in the server configuration’ in windows event viewer.
    You can fix it by un-commenting/enabling ‘mod_filter’ module from apache’s httpd.conf file.

  16. On 16 Apr 2016 at 22:51, Kenneth Gustine said:

    You should add application/json to your AddOutputFilterByType statement. I was trying to figure out why the output of phpmyadmin was so large. It’s because it sends most of its data via JSON! My 500KB request is now 20KB. Thanks!