Send SubRequest after the Response is shown to the user

rishabh nginx-forum at nginx.us
Tue Feb 14 12:33:56 UTC 2012


I tried using post_action but it was causing delay:

I think this is how post_action works, please correct if am wrong.
1-> Nginx get the REQUEST
2-> Nginx receives the RESPONSE generated by PHP
3-> Nginx sends a SUB_REQUEST to 2nd server (using post_action then
proxy_pass)
4-> Nginx recieves the RESPONSE from the 2nd server
5-> Nginx shows RESPONSE to user.

Here at stage 3 & 4 there is an unecessary delay. The subrequest I am
sending is just for analytics and dont want the response to the user be
delayed. The subrequest does not modify the response.

Here is what i want to achieve:
1-> Nginx get the REQUEST
2-> Nginx receives the RESPONSE generated by PHP
3-> Nginx shows RESPONSE to USER.
4-> Nginx generates a SUB_REQUEST to 2nd server
5-> Nginx recieves the RESPONSE from the 2nd server (optional)

Is there any asynchronous module which can be used to achieve the above
flow ?

my conf file file looks like this

http {
server {
location /sendlogging
{
    internal;
    proxy_pass http://localhost:8080/index.php;
}

if($uri = /sendlogging) {
    break;
}

location /
{
    ....
    post_action /sendlogging;
}
}
}

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,222383,222383#msg-222383



More information about the nginx mailing list