We have recently found out about nginxes post_action
.
We were wondering it there was a way to use this directive if a proxy cache hit is made?
The flow we were hoping on is as follows:
1) User request comes in
2) If cache HIT goto A / If cache MISS goto B
A) 1) Serve Cached Result
A) 2) post_action to another url on the backend
B) 1) Server request from backend
B) 2) Store result from backend
Any ideas if this is possible via post_action or any other method?
The reasoning behind this is as follows:
We would in essence like to modify the users session (php, but the same concept can apply to most server side languages) while displaying cached content. This would greatly increase the number of cache-able requests we process since these requests only WRITE to sessions, not read from them.
Thanks!
If you didn't solve it yet here is example config that pass your requirements:
I haven't tested this but you may be able to achieve it with try_files.
Another assumption we are both making is that the post_action receives all the same HTTP headers as the parent request.