How does mod_perl module caching work?

T

tszming

Hello,

I have complied my apache (1.3.41) to use mod_perl, and in the
httpd.conf I added the following:

<Location /cgi-bin/>
PerlModule Apache::DBI
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
allow from all
PerlSendHeader On
</Location>

I was able to run the perl script, but seems mod_perl never cache my
modules?


E.g.

TestModPerl.pm
==============================
use strict;

package TestModPerl;

sub new {

my ($class) = @_;

my $self = {
name => "foo"
};

bless $self, $class;

return $self;
}

1;


test.cgi
==============================
#!/usr/bin/perl

use lib "./../lib/";
use TestModPerl;

print "Content-type:text/html\n\n";

$t = new TestModPerl();
print $t->{"name"};


-------------------------------

After started Apache, even if I modify the TestModPerl.pm by editing
the name, the change is done realtime.

So how does mod_perl module caching work?


Best Regard,
Howa
 
J

Joost Diepenmaat

tszming said:
Hello,

I have complied my apache (1.3.41) to use mod_perl, and in the
httpd.conf I added the following:

<Location /cgi-bin/>
PerlModule Apache::DBI
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
allow from all
PerlSendHeader On
</Location>

I was able to run the perl script, but seems mod_perl never cache my
modules?

If you use the PerlModule directive inside a conditional directive (like
<Location>), it will load the module the first time that location is
visited, by which time you've usually got more than one apache child
process running. That means when you reload the page, chances are fairly
good you've got another child process and the module will get loaded
again for that child. The same thing applies to the scripts in the
/cgi-bin/ directory.

http://perl.apache.org/docs/1.0/guide/performance.html#Preloading_Perl_Modules_at_Server_Startup
 
P

Peter Makholm

tszming said:
After started Apache, even if I modify the TestModPerl.pm by editing
the name, the change is done realtime.

Apache::Registry checks the caches the mtime of the script and
recompiles the script if the mtime changes. This way everything works
as expected for cgi-scripts unless you're doing unusable things.

//Makholm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top