Code Snippet
Active Gzip Compression
Compression reduces response times by reducing the size of the HTTP response. Gzip is the most popular and effective compression method currently available and generally reduces the response size by about 70%. Approximately 90% of today's Internet traffic travels through browsers that claim to support gzip.
# BEGIN GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# END GZIP
What happens to the 10% who don’t support it?
Under Apache 2 better use mod_deflate
I’ve never understood how to get GZIP working. By just copying this into the .htaccess it will GZIP all my content?
Some server don’t support it. This might be the reason, why it’s not working for you. The example above will compress the follwing file types:
- text
- html
- xml
- css
- js
Important is not the file extension, but how the server handles the files. Images – no matter what format – will not be compressed with this setting. This wouldn’t make sense, because all image types already use compression in one way or the other. And these compression methods are much more effective in handling bitmaps (image data).
Does this have a downside?
What happens in browsers which do not support gzip when using this?
I have a question as a .htaccess noob.
How does this code work?
I have added it to mu .htaccess file and Yslow in FireBug says that I do not have gzip compression?
Any ideas
i want to know where is the located .htaccess file where is put this above code and also tell me whats the procedure to do this gzip/deflat integration.
i have add that string but did not work. my server use apache 2
I use this one for gzip and deflat
# BEGIN GZIP
# mod_gzip compression (legacy, Apache 1.3)
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|xml|txt|css|js)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# END GZIP
# DEFLATE compression
<IfModule mod_deflate.c>
# Set compression for: html,txt,xml,js,css
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
# Deactivate compression for buggy browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
# Set header information for proxies
Header append Vary User-Agent
</IfModule>
# END DEFLATE
what do you think about this code?
I use this to gzip my php pages
php_value output_handler ob_gzhandler
it doesn’t work with flush() in php
does any compression work with flush()
DigWP
A book and blog co-authored by Jeff Starr and myself about the World's most popular publishing platform.
Quotes on Design
Design, like Art, can be an elusive word to define and an awfully fun thing to have opinions about.
HTML-Ipsum
One-click copy to clipboard access to Lorem Ipsum text that comes wrapped in a variety of HTML.
Bookshelf
Hey Chris, what books do you recommend? These, young fertile mind, these.