How does mod_perl module caching work?

Discussion in 'Perl Misc' started by tszming, Oct 13, 2008.

  1. tszming

    tszming Guest

    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
     
    tszming, Oct 13, 2008
    #1
    1. Advertising

  2. tszming <> writes:

    > 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

    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
     
    Joost Diepenmaat, Oct 13, 2008
    #2
    1. Advertising

  3. tszming <> writes:

    > 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
     
    Peter Makholm, Oct 13, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frank Rizzo

    Exactly how does caching work?

    Frank Rizzo, Feb 12, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    346
    Frank Rizzo
    Feb 12, 2006
  2. Replies:
    2
    Views:
    453
    Big and Blue
    Jan 25, 2006
  3. Replies:
    9
    Views:
    93
    -berlin.de
    Sep 19, 2006
  4. $r not work in mod_perl 2

    , Jan 6, 2007, in forum: Perl Misc
    Replies:
    4
    Views:
    132
    Brian Wakem
    Jan 7, 2007
  5. howa

    Memory caching in Apache/mod_perl

    howa, Nov 17, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    350
    Mark Clements
    Nov 17, 2007
Loading...

Share This Page