httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@ai.mit.edu (Robert S. Thau)
Subject Re: Those pesky .htaccess files
Date Fri, 07 Jul 1995 09:33:15 GMT
   Date: Fri, 7 Jul 1995 13:01:29 +0100 (BST)
   From: Mark J Cox <M.J.Cox@bradford.ac.uk>
   X-Sender: mjhcox@compute
   Precedence: bulk
   Reply-To: new-httpd@hyperreal.com

   How about the option of caching the fact that a .htaccess file does or
   doesn't exist in each directory?  You could nominate directories to
   be cached (so ~/ directories for instance wouldn't be to allow users to
   change .htaccess files immediately, others would wait until the server 
   was restarted).  

Hmmm... see below for non-cache ways to turn off reading of .htaccess
files in particular directories given the current setup; I'm not sure
they'll all be adequate, but I'd like to know how they break...

FWIW, one idea I've played with is to remember the presence or
absence of the .htaccess file in a directory, and also remember the
relevant last-modified times --- then you could keep the current
behavior (always reread .htaccess files if they change), by stat()ing
the directory itself, and only looking for a .htaccess file where
there used to be none if the last-mod date had changed.  The idea here
is that in the common case (directory in cache), you never wind up
stat()ing a file which *does not exist* --- that could be faster on
file systems which have lookup caches, but don't cache nonexistent
files (AFS being a prime offender, since its performance on a cache
miss is just horrendous).

   This could be complex; but even just saying in a config file:

   NoAccessFile /usr
   NoAccessFile /usr/local
   NoAccessFile /usr/local/etc
   NoAccessFile /usr/local/etc/httpd

FWIW, Shambhala does not currently look for a .htaccess file if there
is a <Directory> section in the access file, or if AllowOverride None
is set.  That means that:

   <Directory /usr>
   </Directory>

(which is admittedly ugly as hell) would have the effect of the
"NoAccessFile /usr" directive.  Alternatively, to take it all at one
blow, you could try something like

   <Directory />
   AllowOverride None
   </Directory>

   <Directory /usr/local/etc/httpd/htdocs>
   Options ...
   AllowOverride ...
   </Directory>

... which *should* (though beware... I haven't checked) disable
.htaccess files server-wide, and reenable them solely in the htdocs
directory.  The trouble with that arrangement is that .htaccess files
also have to be specifically reenabled for UserDirs, and without
wildcard <Directory> specs (yet ;-), it becomes difficult to do that.

   Would save four stats per request!  Has anyone profiled Apache/Shambhala
   to see how much time is wasted on these stats per request?

Last time I tried, it seemed to get about 30% faster (with CGI scripts
disabled and factored out of the mix) if .htaccess files were disabled
completely (even the NCSA base code doesn't bother looking for them
where AllowOverride None is in effect, so you can do this in the
config files).

Some crude statistics indicated that about half of the stat()s for
.htaccess files were for the top few directories (/fs, /fs/web,
/fs/web/docs), so in my case, I figure it would ultimately save 15% to
skip those stat()s --- not overwhelming, but not chicken feed.

rst

Mime
View raw message