I have an apache server whose main purpose is to handle RPC requests. All such requests hit a url that begins with a fixed prefix (e.g., /rpc) I use a Location directive to set the handler for this URL (e.g., <Location /rpc>...</Location>).

I'd now like this server to also serve static files. I put an index.html file into its DocumentRoot but cannot get apache to serve it to me. Instead, I get 404 responses. The access log shows this:

I think this question turned out to be more appropriate for StackOverflow.com. If anyone powerful enough to move/migrate this question over to there agrees with me, please do so.
–
John SiracusaAug 24 '10 at 4:06

1 Answer
1

The answer turned out to hinge on a piece of information not present in my question—but the dtruss output should have been a big hint!

I have a PerlMapToStorageHandler Apache2::Const::OK directive in my apache configuration as per the suggestion in the mod_perl documentation. This is a host-wide setting and it prevents apache from calling ap_directory_walk() and stat()ing a bunch of files every time it gets a request. This is desirable when all of your URIs are "virtual" (i.e., don't correspond to real files on disk) but it also means that you can't serve any static files!

My solution was to create a custom PerlMapToStorageHandler routine that avoids the stat() calls for every file except the one I want to serve: