Post_action only when the download is completed

i have a problem with post_action on nginx.conf.
And sorry for my bad English :slight_smile:

User come to my page an start a download.
Now i have add the post_action and add the download_end.php
in the download_end.php i will count the download stats (write into
database).
That work very beautifully without any error.

The problem is now, when the user cancel the download
download_end.php will execute, but thats false!

Only when the download is realy completed, than i will open
download_end.php
but NOT when the user canceled the download!

Are there any tricks?

Thank you for your help

   location /files/ {
       internal;
       alias /home/files/;
       post_action /download-stop;
   }

   location /download-stop {
       fastcgi_pass 127.0.0.1:9000;
       fastcgi_param SCRIPT_FILENAME

/var/www/page/download_it_end.inc.php;
fastcgi_param QUERY_STRING file_id=$file_id; //thats ok!
fastcgi_param REMOTE_ADDR $remote_addr;
}