Forum Moderators: phranque

Message Too Old, No Replies

httpd.conf versus .htaccess

         

Thomas2000

12:17 am on Mar 6, 2010 (gmt 0)

10+ Year Member



I've read in several places regarding placing site-wide directives in httpd.conf rather than the root webspace .htaccess file because of server load considerations. For low traffic sites, it really doesn't matter but, as traffic increases.

My question is when does it become significant in moving the directives from .htaccess to httpd.conf?

I'm not expecting a firm number but a characterization of site functionality to server load. In short, I like to know when it makes a noticable difference.

jdMorgan

2:00 am on Mar 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is one of those "How long is a piece of string?"-type questions. The answer depends on too many factors to quantify in any meaningfully-accurate way.

If you have server config access, then it would be advisable to put all your config code into httpd.conf or the included configuration files from the very start, and not set yourself up for extra work in the future if and when your server bogs down and "it does make a noticeable difference."

The reasons we appear to focus so much on .htaccess here are because most Webmasters are on shared virtual hosting where they do not have server config file access permissions. And those Webmasters who are on dedicated servers or VPSs where they do have server config file access are generally more advanced and don't tend to post as many questions here. We get a few questions about reverse proxies, load-sharing, and making front-end and back-end servers play nice together, but not a lot compared to the "How can I force 'www' in my address bar?" - type questions.

The speed advantage of code in a config file is that it is compiled once at server start-up and then only executed per HTTP request, whereas in .htaccess the code must be both re-compiled and executed for each and every HTTP request. That's an awful lot of wasted CPU cycles...

Jim

Thomas2000

10:38 pm on Mar 6, 2010 (gmt 0)

10+ Year Member



I'm fully away of the explaination as to why.

My question wasn't asking for quantification. It was asking for characterization. A "framework" as it were so as to be able to explain the reasons to others besides the overly generalizations that are widely available.

I understand about the more typical posts for this group. I was hoping for some more insight since my host allows me to add to the config file (vhost.config) per support ticket. I leaving a host who allowed total root access, vhost.config, to one whereas I don't have root access but can add to it as necessary. I hoping to learn some insight to recognize when it can be an issue for the sites I work.

jdMorgan

5:46 am on Mar 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK. I tried. Sorry to offend you.

Perhaps someone else can offer you a more useful answer, other than "it will be slower."

Jim

Thomas2000

5:09 pm on Mar 7, 2010 (gmt 0)

10+ Year Member



No apology necessary. I half expected the answer you gave. I do very much appreciate the effort at least to try to answer it.

It's just as we learn this stuff, having an answer other than of the "because it's the right way" is significantly better so that we can justify an approach to a customer against one who says it isn't needed.

Losing work to competition with better skills/capability is one thing. Losing it to someone who believes the <blink> tag should be supported in current browsers is a bit annoying.