Preloading modules and compiling

When mod_perl starts, it has to load the modules used by your scripts:

...
use strict;
use DBI();
use CGI;
...

In the normal way of Perl, as modules are called by scripts, they are compiled — Perl scans them for errors and puts them into executable format. This process is faster if it is done at startup and particularly affects the big CGI module. It can be done in advance by including the compile command:

...
use strict;
use DBI();
use CGI;
CGI->compile(<tags>);
...

You would replace <tags> by a list of the CGI subroutines you actually use.

Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.