James I Hightower wrote:
>
> Joshua,
>
> I have some questions related to the $Response->Include() with caching layer
> support and subs:
>
> How do I ensure my subs are cached?
>
> Does the Apache::ASP module automatically compile once and cache all subs(in
> *.pm files) called from my .asp and .html scripts? Do I need to place my .pm
> files in startup.pl to have the subroutines compiled once and cached at server
> startup time? Or are the subs compiled and cached the first time they are
> called from the .asp or .html scripts?
>
One of two strategies result in the optimal compiling of subs
in the parent httpd, automatically shared with all child forks
off the web server:
1) normal mod_perl load directives like
# httpd.conf
<Perl>
use lib qw($CustomLibDir);
<Perl>
PerlModule $ModuleName
- or -
# httpd.conf
PerlRequire some_loader.pl
...
# some_loader.pl
use lib qw($CustomLibDir);
use $ModuleName;
2) Precompile ASP scripts, and have global.asa load modules
# httpd.conf
<Perl>
Apache::ASP->Loader($path, $pattern, %config)
</Perl>
then in global.asa pointed to by %config:
# global.asa
use lib qw($CustomLibDir);
use $ModuleName;
> Assuming my subs are being cached, is it more efficient to place my subs in
> .pm files or in .inc files using the $Response->Include() caching layer
> support?
>
$Response->Include is less efficient because it will stat()
the include file each time, plus some other Include() overhead.
Assuming a perl module has been loaded already, calling a sub
by itself will be faster.
$Response->Include has always cached code compilations. Just
like perl modules cache subroutine compilations. The new
cache layer is about caching the output from the execution
of the include, so it does not have to be reexecuted. This
can help a lot say for building pages that rely on lots
of heavy SQL fetching mostly static data.
> Would it be better to use the Include functionality just for HTML and use subs
> for perl logic?
>
Yes. Decomposition of perl logic into perl modules creates
cleaner templates, and promote reuse of your perl logic besides.
If you ever want a perl sub to call back into ASP, you can access
the ASP objects from any perl package like:
$main::Response->Include();
--Josh
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks Founder Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]