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

Quintin Par quintinpar at gmail.com
Wed Apr 4 04:08:25 UTC 2012


Hi all,

Can someone please help me on this? The pattern is similar to

proxy_cache_use_stale  updating

but just that the backend request is a fire-and-forget.

If I am to do this in SSI I’ll end up spending time to service the code
path in SSI whereas there is no much need to that urgently.

The next cache bypass will update it and that’s good enough for me.

-Quintin

On Tue, Apr 3, 2012 at 12:13 PM, Quintin Par <quintinpar at gmail.com> wrote:

> 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/20120404/3673dd6c/attachment-0001.html>


More information about the nginx mailing list