ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП |
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы. |
19.5. Making CGI Scripts EfficientProblemYour CGI script is called often, and the web server is suffering as a result. You'd like to lessen the load your CGI script causes. SolutionUse Alias /perl/ /real/path/to/perl/scripts/ <Location /perl> SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI </Location> PerlModule Apache::Registry PerlModule CGI PerlSendHeader On DiscussionUsing the The snippet above says that requests with URLs starting in /perl/ are actually in /real/path/to/perl/scripts/ and that they should be handled by Apache::Registry. This runs them in a CGI environment. /perl/ works analogously to /cgi-bin/. To make the suffix .perl indicate <Files *.perl> SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI </Files> Because the Perl interpreter that runs your CGI script doesn't shut down when your script is done (as normally happens when the web server runs your script as a separate program), you cannot rely on your global variables being undefined when the program starts. -w and Don't worry about how big your web server processes appear to grow from pre-loading all these scripts. They need to find their way into memory eventually, and it's better to happen before Apache forks off kids. That way each script has to be in memory only once, because forked children have shared memory pages (under all modern operating systems). In other words, it only appears to take up more memory this way. It actually takes less! An interface to Netscape's server is also available at http://www.perl.com/CPAN-local/modules/by-module/Netscape/nsapi_perl-0.24.tar.gz that effects a similar performance gain by avoiding forking. See AlsoThe documentation for Bundle::Apache, Apache, Apache::Registry, from CPAN; http://perl.apache.org/, mod_perl FAQ at http://perl.apache.org/faqa/, the mod_perl (3) and cgi_to_mod_perl (1) manpages (if you have them) |