# Send SubRequest after the Response is shown to the user

**URL:** <https://www.ruby-forum.com/t/send-subrequest-after-the-response-is-shown-to-the-user/216799>\
**Category:** NGINX\
**Created:** [February 14, 2012, 1:34pm UTC](https://www.ruby-forum.com/t/send-subrequest-after-the-response-is-shown-to-the-user/216799 "2012-02-14T13:34:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [February 14, 2012, 1:34pm UTC](https://www.ruby-forum.com/t/send-subrequest-after-the-response-is-shown-to-the-user/216799/1 "2012-02-14T13:34:47Z")

</div>

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](http://localhost:8080/index.php);  
}

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

location /  
{  
…  
post\_action /sendlogging;  
}  
}  
}

Posted at Nginx Forum:

> **[Send SubRequest after the Response is shown to the user](https://forum.nginx.org/read.php?2,222383,222383#msg-222383)**
>
> 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...
