Mark Stosberg wrote:
> I just discovered mod_perl's internal_redirect method. I was looking for
> something like that for a routine that looks up some details and then
> redirects to an image file.
> 
> From benchmarking, it's only 2% slower than directly fetching the image
> file, and 7% faster than using an external direct. Further, the result
> produces a "Last-Modified" header based on the final image, which is
> what I want, as it allows browser caching to work on the image.
> 
> The code is also rather simple:
> 
>         if ($ENV{MOD_PERL}) {
>             my $r = Apache->request;

Just FYI, this call is pretty fast under mod_perl 1, but can be really slow
under mod_perl 2 in a non-prefork mpm.

>             $r->internal_redirect($url);
>             use Apache::Constants 'OK';

I'm sure you know this, but just for posterity, putting the "use" there doesn't
make it conditional.

>             return OK;
>         }
>         else {
>             $self->header_type('redirect');
>             $self->header_props(
>                 -url => $url
>             );
>         }
> 
> However, I wanted to check with more experienced modperl/CGI::App users
> about this approach. I think have short-circuited the CGI::App flow with
> approach, preventing "teardown" from being called. 

Are you sure it prevents teardown? If you're calling run() (running it as an
Apache::Registry script, or using something like C::A::Dispatch or
C::A::P::Apache) then all C::A phases will execute, right?

> That's OK in this
> case, but is there another "Gotcha" here I missed?

Not that I can think of. If you know you're running under mod_perl, then you
should be able to use the full mod_perl API.


-- 
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to