0

I have deflate module enabled but when I put my code in .htaccess, it is not working. On various websites I have tested and it shows me to enable gzip compression. Below is the code for deflate:

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/opentype

    # For Olders Browsers Which Can't Handle Compression
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

When I enable deflate in terminal, this is the message that I get:

sudo a2enmod deflate

Considering dependency filter for deflate:
Module filter already enabled
Module deflate already enabled

MrWhite
  • 11,643
  • 4
  • 25
  • 40
  • Try removing the `` wrapper. Add the HTTP response headers for say a CSS file to your question. – MrWhite Dec 12 '16 at 08:52
  • Which version of apache are you using? If you use 2.4 you do not need to use the and – Orphans Dec 12 '16 at 09:14
  • @Orphans Why does the Apache _version_ determine whether you need the `` wrapper? – MrWhite Dec 12 '16 at 09:20
  • @w3dk Apache 2.4 does not need it on some modules and on DEFLATE it is not needed. – Orphans Dec 12 '16 at 10:01
  • @Orphans With regards to mod_deflate, that has nothing to do with the Apache version. The same would apply to Apache 2.2/2.0. The `` wrapper is arguably required here since you are also setting environment variables with mod_setenvif - and these should only be set if mod_deflate is enabled. Of course, if the system is only expected to function with mod_deflate enabled then remove the `` wrapper (it should fail with an error in such cases, rather than fail silently). mod_deflate is not a core module in any version of Apache - so this applies to all versions. – MrWhite Dec 12 '16 at 10:25
  • @w3dk Alright, I understand. Thank you for explaining. – Orphans Dec 12 '16 at 11:11
  • Got it working guyz, it was not an issue with ``. I have placed it inside the `.conf` file instead of `.htaccess` and it is working good. Thanks for help anyways. – Abhishek Dhanraj Shahdeo Dec 12 '16 at 13:59

0 Answers0