Forum Moderators: phranque

Message Too Old, No Replies

mod deflate

syntax of coding in htaccess

         

Broadway

9:33 pm on Aug 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I want to take advantage of mod_deflate (which my host says is enabled). However, I'm unexperienced in .htaccess syntax. I've looked around and came up for this code for my htaccess files. Would someone mind passing judgement on it? Does it seem correct or adequate?

I use htm, html, js, css, swf, jpg, gif, png, ico file types on my site. I'm trying to compress the non-image file types.
Thanks.


<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpg|ico|png|swf)$ no-gzip dont-vary
# Dealing with buggy browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
# Make sure proxies deliver correct content
Header append Vary User-Agent env=!dont-vary
</IfModule>

jdMorgan

4:01 pm on Aug 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Any mod_deflate experts in the house?

<bump>

Jim

Broadway

4:38 pm on Aug 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I got a reply from my host's support staff.

>>Yes, the below looks like it should compress content except for the gif, jpg, ico, png and swf extensions, with the exceptions made for browsers and proxies on the mod_deflate suggested configuration from Apache.<<

I'd be surprised that my coding is really the most efficient or best way to do this (usually there is some discussion on WW about that sort of thing in these threads) but hopefully it's appropriate. I'll go ahead and implement it and report on my experiences and findings.

Broadway

8:01 pm on Aug 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I implemented the above code and used an online "compression" checker. It reported compression for html, xml, js, and css files. It reported no compression for image files. So all seems in order.

I didn't check in regards to "buggy browsers" and how the code implements for them.

If anyone sees the code and has comments on any "polishing up" it might need I would like to hear them.