Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to do an additional request for each request served by Nginx?

I have a MySQL database in which I store an ID and the number of impressions for each content ID. Each time a dynamic page is generated I increment the impressions value for the corresponding ID. I want to do the same for static content, I therefor would like to call a Perl script to update the database as a sub-request or in background.

I tried using the Embedded Perl Module, this can do the update in MySQL but I am unable to serve the requested page once the update has been done. Is it possible to call this Perl module as a sub request, or are there any alternatives?

In short, this is what I'm trying to do: request static page: http://mysite.com/document/12345.html -> run a script to update the number of impressions for ID 12345 -> return static file 12345.html

share|improve this question

1 Answer 1

http://wiki.nginx.org/HttpCoreModule#post_action will do what you're asking in the opposite order, which will get the response to the client faster.

share|improve this answer
    
That was easy. Thank you very much!! –  Dee Feb 27 '12 at 18:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.