Re: [Templates] A problem with document caching?

[prev] [thread] [next] [Date index for 2004/09/20]

From: Tosh Cooey
Subject: Re: [Templates] A problem with document caching?
Date: 22:48 on 20 Sep 2004
Perrin Harkins wrote:

> On Sun, 2004-09-19 at 17:10, Tosh Cooey wrote:
> 
>>This all works fine under a normal Apache CGI environment, but once the script 
>>is running under ModPerl::Registry, or even ModPerl::PerlRun I am not getting 
>>the correct files served.
>>
>>For example, www.site.com/view.pl?product=xyz might actually show me the result 
>>of www.site.com/view.pl?category=foo.
> 
> 
> Your code probably has a closure in it somewhere.  For example, this
> will break in any persistent environment (FastCGI, PerlEx, mod_perl,
> etc.):
> 
> my $cgi = CGI->new();
> 
> do_something();
> 
> sub do_something {
>     my $product = $cgi->param('product');
>     print $product;
> }


Yes and no.  The code looks like this:

use lots of modules;
exit(&main);
sub main {
	my $pageOBJ = Template->new({    ABSOLUTE => 1,
		START_TAG => quotemeta('[*'), END_TAG => quotemeta('*]') });
	my $in = new CGI;
	do stuff...
	my $cached_page = &getFilename($in);  # passing the CGI object
	do stuff...
	$pageOBJ->process($cached_page, $vars) || die $pageOBJ->error(), "\n";
}

sub getFilename {
	if requested file is old or not cached then (re)build the file
		my $pageOBJ = Template->new({ABSOLUTE => 1, OUTPUT => $file});
		do stuff...
		$pageOBJ->process($page, $vars) || die $pageOBJ->error(), "\n";
	}
	return $file;
}

So the code is fairly structured, and I can't see the "break" you mean, but I 
can see how that would cause a problem.

However I still think the fact that I have three Template objects open during 
the running of this script could be a problem.

But if it could be the CGI being a problem then perhaps the httpd.conf can help?

PerlSwitches -I/usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd/Apache2
PerlOptions +SetupEnv
PerlModule Apache::compat
PerlModule Apache::DBI
PerlModule Apache::AuthDBI
PerlModule CGI
PerlInitHandler Apache::Reload
PerlSetVar ReloadAll Off
<VirtualHost CLIENT>
  <Directory /web/client>
   Options +ExecCGI
   PerlOptions +ParseHeaders
   <Files ~ "\.(pl)$">
    SetHandler perl-script
    PerlHandler ModPerl::PerlRun
   </Files>
  </Directory>
</VirtualHost>

Does loading CGI as a module cause problems?  I read that it's actually a "slow" 
module to load, and so doing this helps speed it up.

Thank-you,

Tosh

        -- 
        McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] A problem with document caching?
Tosh Cooey 21:10 on 19 Sep 2004

Re: [Templates] A problem with document caching?
Buddy Burden 17:16 on 20 Sep 2004

Re: [Templates] A problem with document caching?
Perrin Harkins 19:38 on 20 Sep 2004

Re: [Templates] A problem with document caching?
Tosh Cooey 22:48 on 20 Sep 2004

Re: [Templates] A problem with document caching?
Perrin Harkins 00:00 on 21 Sep 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52