Welcome! Log In Create A New Profile

Advanced

Re: Handler modules : Content Handler vs Content Phase Handler

Maxim Dounin
September 04, 2015 02:48PM
Hello!

On Fri, Sep 04, 2015 at 12:56:24PM -0400, goldfluss wrote:

> Hello !
> I'm developping some handler modules for nginx and I'm wondering why they
> are two kinds of handlers :
> - Content Phase Handler
> - Content Handler
>
> I read this interesting blog : http://www.nginxguts.com/2011/01/phases/
> As far as I understood, the content handler could only be called once in a
> location configuration and the content phase handler is called everytime.
> Is there a reason to prefer one type instead of another?
>
> My last question is if there is a solution to develop content phase handler
> modules without calling them each time, but only if they are activated in
> the nginx.conf file?

Content handlers are unconditionally called for a location, and
they override any default content phase handlers. Hence content
handlers are used by such modules as proxy, fastcgi, memcached,
empty_gif and so on - when all (or almost all) requests in a
location are expected to be handled by a particular module.

In contrast, content phase handlers are called in order, much like
any other phase handlers. There is no way to avoid calling a
content phase handler in a particular configuration. Instead, a
handler should check the configuration itself, and return
NGX_DECLINED if it's not configured to do anything.

That is, you should use content handlers for modules like proxy,
when you want requests to be handled in a particular way in a
given location. And you can use content phase handlers (which are
more expensive compared to content handlers), when you want to
implement something more generic and selective, i.e., to only
handle certain requests, like index or autoindex modules.

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Handler modules : Content Handler vs Content Phase Handler

goldfluss September 04, 2015 12:56PM

Re: Handler modules : Content Handler vs Content Phase Handler

Maxim Dounin September 04, 2015 02:48PM

Re: Handler modules : Content Handler vs Content Phase Handler

goldfluss September 05, 2015 10:27AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 264
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready