Looking for feedback on my httpd.conf file

bassicmusic

New Member
I am going to be making some changes to the httpd.cong file for one of my websites to make it load faster. Right now, I'm focusing on 1) enabling gzipping for text-type files via mod_deflate and 2) leveraging browser caching for static files (e.g., images, css style sheets) via mod_expires.

After doing a fair amount of reading up on the subject, I have come up with what I think is suitable code. I also set up a test folder on my website with its own .htaccess file and ran Google's Page Speed, Web Page Test, and several other online testers, and so far as I can tell, things look pretty good. At some point, I would like to update my website's httpd.conf file to include the code from my test folder's .htaccess file, but before I do so, I would like to get a second opinion to see if it can be improved upon.

So far as the gzipping part is concerned, a Tech Support person who works for westhost.com (where my website is hosted) published a post on their blog with some suggestions on what to add to your website's httpd.conf file to enable gzipping. Since this advice is coming from someone technical who is on the staff of westhost.com, I feel reasonably certain it should work on my website as that is where it is hosted - but unfortunately, the code in this post does not include any lines that deal with older browsers (e.g., IE 6.0) that don't recognize gzipping.

What I am looking for is someone who is familiar with Apache and .htaccess to look over what I've written to tell me whether or not my code looks all right.

What I would like to know in particular is

1) My code seems to work as a .htaccess file, but can I include it as is, line for line, in my website's httpd.comf file, or are there any modifications I need to make?
2) Will the three lines starting with "BrowserMatch" handle older browsers such as IE Explorer 6.0 than cannot handle gzipping?
3) Does the block of code starting with "Module mod_expires.c" look alright?

Thank you.

Here is a copy paste of my file.



# BEGIN
<IfModule mod_expires.c>
<Filesmatch "\.(jpg|jpeg|png|gif|js|pdf|css|flv|swf|ico)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
</Filesmatch>
</IfModule>
#
# All the following statements between the opening and closing IfModule tags (except for the BrowserMatch statements) are from
# Nick Venturella's WestHost blog post dated 2009-06-09. Note: I left out his statements for xml because there are other clients (e.g., RSS
# readers) besides browsers that can access xml and I'm not 100% sure they can all handle gzipping.
# The BrowserMatch statements (from http://httpd.apache.org/docs/2.0/mod/mod_deflate.html) are for certain antiquated browsers
# that have problems with gzipping.
#
<IfModule mod_deflate.c>
SetInputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/rtf
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/postscript
AddOutputFilterByType DEFLATE application/msword
AddOutputFilterByType DEFLATE application/vnd.ms-excel
AddOutputFilterByType DEFLATE application/vnd.ms-powerpoint
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
# END
 

MarkR

New Member
I reckon you'd actually be better off using .htaccess for this, it's easier to figure out and easier to revert if it goes sideways.

Here's a freebie that I implement in .htaccess for compression in my sites:


Code:
<IfModule mod_deflate.c>

# Insert filter
SetOutputFilter DEFLATE
 
# 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
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
 
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

</IfModule>
 
Top