How to enable G-Zip compression on apache2

Have you created a useful tool? or Do you want to get help building one? This is the right place!
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
Shaka
Posts: 277
Joined: Wed Jun 13, 2007 7:43 pm
Location: VENEZUELA
Contact:

How to enable G-Zip compression on apache2

Post by Shaka »

Good guys, this little guide will help to improve the speed of loading web pages on our site.

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 
add this line at end of file:

Code: Select all

 # G-zip / DeflateInclude conf/extra/httpd-deflate.conf 
save

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>
save

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%) 
Test your website: http://www.whatsmyip.org/http_compression/
Last edited by Shaka on Thu May 12, 2011 6:08 pm, edited 5 times in total.
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: How to Enable G-ZIP compression.

Post by jurchiks »

Interesting and valuable, thanks :)
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
User avatar
Shaka
Posts: 277
Joined: Wed Jun 13, 2007 7:43 pm
Location: VENEZUELA
Contact:

Re: How to Enable G-ZIP compression.

Post by Shaka »

and I tried and it works well.

logically copy, paste and test.
User avatar
Shaka
Posts: 277
Joined: Wed Jun 13, 2007 7:43 pm
Location: VENEZUELA
Contact:

Re: How to Enable G-ZIP compression.

Post by Shaka »

updated, I forgot to fix the route logs and enable mod_headers.so
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: How to enable G-Zip compression on apache2

Post by jurchiks »

Bad trolling skills...
How are you posting this if you "can't go on the internet without it"?
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Post Reply