Forum Moderators: phranque

Message Too Old, No Replies

htaccess vs httpd.conf

Which is faster for gzip?

         

madmatt69

8:48 pm on Nov 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

I've got some gzip code in my standard .htaccess that I use for all the sites on my server.

I'm wondering if I can put that code in my httpd.conf instead, and if there is any performance benefit in doing so?

Thanks!

pontifex

11:28 pm on Nov 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



matt,

.htaccess is a "per request" base and httpd.conf is for all request (if not conditioned otherwise) - so, if you have that code for all your sites, put it into httpd.conf!

P!

phranque

12:17 pm on Nov 12, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



it's a server efficiency issue as well as a configuration management issue.

put another way, the .htaccess file is interpreted and processed each time that directory or a subdirectory is accessed by the server whereas the httpd.conf is processed only when the server is (re)started.

jdMorgan

1:47 pm on Nov 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Careful with the terms and details here, gents...

Code in httpd.conf or conf.d is compiled --translated from characters into machine code-- once at server restart, while code in .htaccess in interpreted --translated from characters into 'tokens' to be further processed-- for each and every HTTP request that resolves to or transits the directory in which the .htaccess code resides.

So, in general, putting your code into httpd.conf, conf.d, or other server-configuration file will result in much-more-efficient processing of that code as compared to .htaccess. This is traded off against the requirement of restarting the server if any changes are made to the code in httpd.conf. And of course, most Webmasters are on shared hosting and don't have the luxury of making any changes to the server configuration files.

Jim