Invalidate just one page under a location directive.

António P. P. Almeida appa at perusio.net
Wed Feb 8 17:10:34 UTC 2012


On 8 Fev 2012 16h22 WET, quintinpar at gmail.com wrote:

> Invalidate a cache page using the bypass mechanism
> proxy_cache_bypass, not expiration

IMHO the best option would be from the application side send a
'X-Accel-Expires: 0' header. But this needs to be done at the *app
level*.

Unless you place something in the headers that the application returns
Nginx there's no way of Nginx to know what is going on.

> To put it simply, Invalidate cache for a particular key entry but
> not all of the cache

> e.g for
>
> location = /vehicles {
>
> proxy_cache_key         $request_uri;
>
> }
>
> Hashtable for cache:
>
> [
>
> http://jj.com/vehicles/cars => cached page for cars
>
> http://jj.com/vehicles/bus => cached page for bus
>
> http://jj.com/vehicles/bike=> cached page for bike
> + 10,000 key, values
> ]


> I should be able to invalidate just "cars" because my page for cars
> have changed but not others. Say a person added a comment in the
> cars page.  Another analogy is to invalidate cache for a single blog
> post when all the blog posts have been cached under a single
> location directive.  -Quintin

Send a 'X-Accel-Expires: 0' header from the application at: 

http://jj.com/vehicles/cars

--- appa



More information about the nginx mailing list