http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
is very easy.
apache 2.2 server in our open our file configuration:
httpd.conf
find the line that says: mod_headers.so and mod_deflate.so
edit a line to enable the module, just remove a #
httpd.conf
Code: Select all
LoadModule deflate_module modules/mod_deflate.soLoadModule headers_module modules/mod_headers.so
Code: Select all
# G-zip / DeflateInclude conf/extra/httpd-deflate.conf
Now create a file in the extra/httpd-deflate.conf
copy this code:
httpd-deflate.conf
Code: Select all
<IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/htmlAddOutputFilterByType DEFLATE text/plainAddOutputFilterByType DEFLATE text/xmlAddOutputFilterByType DEFLATE text/cssAddOutputFilterByType DEFLATE text/javascriptAddOutputFilterByType DEFLATE text/x-jsAddOutputFilterByType DEFLATE application/xhtml+xmlAddOutputFilterByType DEFLATE application/xmlAddOutputFilterByType DEFLATE application/rss+xmlAddOutputFilterByType DEFLATE application/atom_xmlAddOutputFilterByType DEFLATE application/x-javascriptAddOutputFilterByType DEFLATE application/x-httpd-phpAddOutputFilterByType DEFLATE application/x-httpd-fastphpAddOutputFilterByType DEFLATE application/x-httpd-erubyAddOutputFilterByType DEFLATE application/javascriptAddOutputFilterByType DEFLATE image/svg+xml # high 9 – low 1DeflateCompressionLevel 9 <IfModule mod_setenvif.c> # Insert filterSetOutputFilter DEFLATE # Netscape 4.x has some problems...BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problemsBrowserMatch ^Mozilla/4\.0[678] no-gzip # MSIE masquerades as Netscape, but it is fineBrowserMatch \bMSIE !no-gzip !gzip-only-text/html # Don’t compress already-compressed filesSetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-varySetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-varySetEnvIfNoCase Request_URI .(?:avi|mov|mp3|mp4|rm|flv|swf|mp?g)$ no-gzip dont-varySetEnvIfNoCase Request_URI .pdf$ no-gzip dont-vary </IfModule> <IfModule mod_headers.c> # Make sure proxies don't deliver the wrong contentHeader append Vary User-Agent env=!dont-vary </IfModule> # logs DeflateFilterNote Input instreamDeflateFilterNote Output outstreamDeflateFilterNote Ratio ratio LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflateCustomLog logs/deflate.log deflate </IfModule>
reboot our server apache.
reviewed in our deflate.log compression.
Code: Select all
GET /icons/unknown.gif HTTP/1.1" -/- (-%)"GET /icons/blank.gif HTTP/1.1" -/- (-%)"GET / HTTP/1.1" 400/749 (53%)"GET / HTTP/1.1" 400/749 (53%)"GET / HTTP/1.1" 400/749 (53%)"GET / HTTP/1.1" 400/749 (53%)"GET / HTTP/1.1" 400/749 (53%)"GET / HTTP/1.1" 400/749 (53%)