This doesn't appear to be possible. The mirror
directive is processed as a subrequest to the original request, so if nginx does not process the original request, the mirror request will also not be processed.
As a workaround, you can add a second custom access_log
directive, which uses a custom log_format
. Your program can then read this log to determine when a cache hit occurred and to which URL. In fact, it could just use that log to count all hits, cached or not.