Mutant has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

If I have a PerlHandler directive in a Location container, will the PerlHandler get loaded into memory even if that Location isn't hit?

eg. if I have

<Location /someurl/> SetHandler perl-script PerlHandler MyHandler </Location>

Will MyHandler get loaded into the child process if no one ever requests http://mydomain/someurl/ from that child process?

(Have consulted Apache/mod_perl docs, but can't seem to find anything relating to this)

Thanks

Replies are listed 'Best First'.
Re: Apache/mod_perl configuration
by Jaap (Curate) on Dec 01, 2004 at 12:49 UTC
    In short: yes it does. You can test it by having the perl script write output to a file. When you restart the server, you will find that the file is written.

    Edit: according to perrin, it doesn't.
      No, it does not. That module will not be loaded until the location is requested. To load it at startup, you would have to call it with a PerlModule or PerlRequire or load it from startup.pl.
      Is there some way to prevent this happening? I assume this occurs accross other containers (such as VirtualHost)?
        It does happen across other containers too yes. I assume you cannot prevent this because it's what mod_perl does: load the thing into memory to be ready when someone makes a request.

        (I'm taking Jaap's answer at face value. I don't remember much about mod_perl.)

        What are you trying to accomplish? There might be other ways of accomplishing what you want to accomplish. One thing you could do is to have a barebones handler that loads up the full module and calls it:

        sub handler { require Full::Module; goto(&Full::Module::handler); }

        (You might have to fool with the args in @_ a little. I don't remember what args a handler receives.)

        Of course, once the module is loaded, it will stay loaded.