Jump to content

mod_deflate settings


Recommended Posts

Posted

I am having annoying issue with mod_deflate.. I have enabled it in apache2 but all those optimization tools keep telling me my content is not zipped.

Here is my mod_deflate settings in deflate.config



<IfModule mod_deflate.c>

# AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

# DeflateCompressionLevel 6

        AddOutputFilterByType DEFLATE text/plain

        AddOutputFilterByType DEFLATE text/html

        AddOutputFilterByType DEFLATE text/xml

        AddOutputFilterByType DEFLATE text/css

        AddOutputFilterByType DEFLATE image/svg+xml

        AddOutputFilterByType DEFLATE image/x-icon

        AddOutputFilterByType DEFLATE application/xml

        AddOutputFilterByType DEFLATE application/xhtml+xml

        AddOutputFilterByType DEFLATE application/rss+xml

        AddOutputFilterByType DEFLATE application/javascript

        AddOutputFilterByType DEFLATE application/x-javascript


        AddOutputFilterByType DEFLATE application/x-httpd-php

        AddOutputFilterByType DEFLATE application/x-httpd-fastphp

        AddOutputFilterByType DEFLATE application/x-httpd-eruby


        DeflateCompressionLevel 5


# Netscape 4.X has some problems

       BrowserMatch ^Mozilla/4 gzip-only-text/html


# Netscape 4.06-4.08 have some more problems

       BrowserMatch ^Mozilla/4\.0[678] no-gzip


# MSIE masquerades as Netscape, but it is fine

       BrowserMatch \bMSIE !no-gzip !gzip-only-text/html


# Setup custom deflate log

#        DeflateFilterNote Input instream

#        DeflateFilterNote Output outstream

#        DeflateFilterNote Ratio ratio

#

#        LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate

# Example of log file (add to vhosts)

#        CustomLog logs/deflate_log DEFLATE

</IfModule>

I have this in .htaccess


AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/xml application/x-javascript


SetEnvIfNoCase Request_URI .* no-gzip dont-vary



Also, gzip encoding from ACP is enabled.

Now my question is:
1. Do I need deflate settings in .htaccess and deflate.conf both? or can someone help me in merging to deflate.conf?
2. The default config is something different:
http://httpd.apache.org/docs/2.2/mod/mod_deflate.html#recommended

Why it has <Location /> and mine starts with <IfModule mod_deflate.c> in deflate.conf?

Can someone please help ? I am using Debian.

Thanks

Posted

Put that in the virtual host and not just the httpd.conf file.




Gary, thanks for all time help but put what? I am really confused on what to put to be honest.. because apache2 example is with location and mine starts with something else..

What exactly I should put in virtual host? After putting in host, can I remove from .htaccess?
Posted

Remove all .htaccess files,

Then add this in your pre virtual host include file:




<IfModule mod_deflate.c>


# AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript


# DeflateCompressionLevel 6


AddOutputFilterByType DEFLATE text/plain


AddOutputFilterByType DEFLATE text/html


AddOutputFilterByType DEFLATE text/xml


AddOutputFilterByType DEFLATE text/css


AddOutputFilterByType DEFLATE image/svg+xml


AddOutputFilterByType DEFLATE image/x-icon


AddOutputFilterByType DEFLATE application/xml


AddOutputFilterByType DEFLATE application/xhtml+xml


AddOutputFilterByType DEFLATE application/rss+xml


AddOutputFilterByType DEFLATE application/javascript


AddOutputFilterByType DEFLATE application/x-javascript



AddOutputFilterByType DEFLATE application/x-httpd-php


AddOutputFilterByType DEFLATE application/x-httpd-fastphp


AddOutputFilterByType DEFLATE application/x-httpd-eruby



DeflateCompressionLevel 5



# Netscape 4.X has some problems


BrowserMatch ^Mozilla/4 gzip-only-text/html



# Netscape 4.06-4.08 have some more problems


BrowserMatch ^Mozilla/4.0[678] no-gzip



# MSIE masquerades as Netscape, but it is fine


BrowserMatch bMSIE !no-gzip !gzip-only-text/html



# Setup custom deflate log


# DeflateFilterNote Input instream


# DeflateFilterNote Output outstream


# DeflateFilterNote Ratio ratio


#


# LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate


# Example of log file (add to vhosts)


# CustomLog logs/deflate_log DEFLATE


</IfModule>





Then restart apache.
Posted

This is how I did it in my conf:



<IfModule mod_deflate.c>

          AddOutputFilterByType DEFLATE text/html text/plain text/xml

          AddOutputFilterByType DEFLATE text/css

          AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript

          AddOutputFilterByType DEFLATE application/rss+xml

</IfModule>

Posted

Remove all .htaccess files,



Then add this in your pre virtual host include file:



Then restart apache.




When you mean to say virtual host file do you mean httpd.conf ?

Thank you!
  • 1 month later...
Posted

he means the place where your site is defined, it might be in a vhost or in that file...

also disable compression from adminCP, that one is CPU expensive (made by PHP), while this one is bether and made in the http server

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...