Serve from cache but fire request to upstream server to increment page view counter

Quintin Par quintinpar at gmail.com
Tue Apr 3 06:43:35 UTC 2012


Hi all,

I have a strange case, not sure if this is addressed by nginx yet

My site is cached as follows.

  location = / {

    proxy_pass  http://localhost:82;

    proxy_set_header   Host             $host;

    proxy_set_header   X-Real-IP        $remote_addr;

    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

    proxy_set_header Accept-Encoding "";

    proxy_ignore_headers Set-Cookie;

    proxy_ignore_headers Cache-Control;

    proxy_ignore_headers Expires;

    proxy_ignore_headers X-Accel-Expires;

    add_header X-Cache-Status $upstream_cache_status;

    proxy_cache             cache;

    proxy_cache_key         $scheme$host$request_uri$cookie_site_sessionid;

    proxy_cache_valid       200 302 30s;

    proxy_cache_use_stale   updating;

  }

One issue I encounter with this is that I can’t increment the page view
counter that I maintain in redis.

Is there is way nginx can fire a request to the backend web – to some URI
so that I can take the request and increment the associated counter?

I know I can achieve this with SSI, but I wanted to check if there is a
better pattern.

-Quintin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120403/2891d4f5/attachment.html>


More information about the nginx mailing list