output filter

Hello,

How to set the filter for some output headers?
I want to add some Expire: and Cache-Control: headers to make
downstream cacheserver to cache the pages.
Though they are dynamic pages, but I think they are safe to be cachable.

Thanks.
moli [ Do, 28 Januar 2010 16:27 ] [ ID #2030143 ]

Re: output filter

On Thursday 28 January 2010 16:27:29 moli [at] normalperson.e4ward.com wrote:
> How to set the filter for some output headers?
> I want to add some Expire: and Cache-Control: headers to make
> downstream cacheserver to cache the pages.
> Though they are dynamic pages, but I think they are safe to be cachable.
>
PerlOutputFilter "sub { \
use strict; \
use Apache2::Filter (); \
use Apache2::RequestRec (); \
use Apache2::Const -compile=>qw/DECLINED/; \
my ($f)= [at] _; \
[at] {$f->r->headers_out}{qw/Expire Cache-Control/}= \
(q{...}, q{...}); \
$f->remove; \
return Apache2::Const::DECLINED; \
}"

Fill in the 2 ellipses.

Torsten
torsten.foertsch [ Do, 28 Januar 2010 17:00 ] [ ID #2030144 ]

Re: output filter

On Thu, Jan 28, 2010 at 10:27 AM, <moli [at] normalperson.e4ward.com> wrote:
> I want to add some Expire: and Cache-Control: headers to make
> downstream cacheserver to cache the pages.
> Though they are dynamic pages, but I think they are safe to be cachable.

If you're generating them with mod_perl, you can just set the headers
in your response handler. You only need an output filter if some of
them are coming from another source, like PHP.

- Perrin
Perrin Harkins [ Do, 28 Januar 2010 17:31 ] [ ID #2030145 ]

Re: output filter

Thanks all.
Yes the whole pages are generated from mod_perl not PHP.

BTW, though we are still using modperl for developing some applications.
But it seems other instead technologies are becoming more and more
popular, like PHP,Django,Rails etc.
Is modperl outdated in today?

Regards.
moli [ Fr, 29 Januar 2010 08:46 ] [ ID #2030517 ]

Re: output filter

On Thu, Jan 28, 2010 at 11:46 PM, <moli [at] normalperson.e4ward.com> wrote:
> BTW, though we are still using modperl for developing some applications.
> But it seems other instead technologies are becoming more and more
> popular, like PHP,Django,Rails etc.
> Is modperl =A0outdated in today?

I don't know that PHP is becoming more popular, I think it's
popularity is actually waning. While Django, and Rails are certainly
popular, I don't think it necessarily follows that modperl is
outdated. It certainly performs better than Django and Rails, but
that isn't necessarily a hard requirement for many places. It's
probably more of business decision these days. Which technology do
your employees know the best, and what's the availability of people
who know that technology in the job market? The pluses and minuses to
each language and technology mostly even out. Chances are if you are
writing webapps your not really going to run across large
differentiating factors between the technologies.

-wjt
William T [ Fr, 29 Januar 2010 11:35 ] [ ID #2030518 ]
Webserver » gmane.comp.apache.mod-perl » output filter

Vorheriges Thema: rewrite url in modperl
Nächstes Thema: mod_perl-2.0.4 with Apache 2.2.9 and perl 5.10.0 intermittent