回复： Re: How to
haifeng.813 at gmail.com
Tue Jan 22 13:33:31 UTC 2013
Content-Type: text/plain; charset="utf-8"
Thank you very much. And for your note, I know the connections are reusable=
, it's not a problem for me. To be sure, during a client is alive, the conn=
ection won't serve other clients, is it correct?
Maxim Dounin <mdounin at mdounin.ru>=E7=BC=96=E5=86=99=EF=BC=9A
On Tue, Jan 22, 2013 at 08:16:36PM +0800, Liu Haifeng wrote:
> hi all,
> I want save state during a long connection (keep-alive) for=20
> performance optimization in my own HTTP handler module, thus I=20
> can peek up the saved state when handling requests, to speed up=20
> response. Actually it's quite like session concept. I saw=20
> request struct has a member ctx, but what I want is a ctx on the=20
> connection. It seems no way to save any customized variable to=20
> the ngx_connection_t structure. What's the suggested way to make=20
> this if I don't want the client hold something like session_id?
This was recently discussed on nginx-devel@ mailing list, and=20
probably the best way currently available is to install connection=20
pool cleanup handler with custom data and then iterate over=20
connection pool cleanup handlers to find your data. It is=20
relatively costly, but allows to keep memory footprint from=20
keepalive connections low and still allows modules to keep their=20
per-connection data in rare cases when they really need to.
Note well though, that HTTP is stateless protocol, and the fact=20
that request came from the same connection means mostly nothing:=20
it might be a request from a completely different user.
nginx mailing list
nginx at nginx.org
More information about the nginx