[PATCH] Cache: check if ETag and Vary didn't change before updating header

Maxim Dounin mdounin at mdounin.ru
Mon Dec 22 13:05:30 UTC 2014


Hello!

On Sat, Dec 20, 2014 at 04:22:57PM -0800, Piotr Sikora wrote:

> # HG changeset patch
> # User Piotr Sikora <piotr at cloudflare.com>
> # Date 1419121345 28800
> #      Sat Dec 20 16:22:25 2014 -0800
> # Node ID 7e7f823e87fc02c55d46d74a65b336752afe17ee
> # Parent  ee941e49bd8899d2beb3da9ec36acf3b56c5ce9e
> Cache: check if ETag and Vary didn't change before updating header.
> 
> Signed-off-by: Piotr Sikora <piotr at cloudflare.com>
> 
> diff -r ee941e49bd88 -r 7e7f823e87fc src/http/ngx_http_file_cache.c
> --- a/src/http/ngx_http_file_cache.c	Wed Dec 17 15:12:50 2014 +0100
> +++ b/src/http/ngx_http_file_cache.c	Sat Dec 20 16:22:25 2014 -0800
> @@ -1362,6 +1362,10 @@ ngx_http_file_cache_update_header(ngx_ht
>  
>      if (h.version != NGX_HTTP_CACHE_VERSION
>          || h.last_modified != c->last_modified
> +        || h.etag_len != c->etag.len
> +        || ngx_memcmp(h.etag, c->etag.data, c->etag.len) != 0
> +        || h.vary_len != c->vary.len
> +        || ngx_memcmp(h.vary, c->vary.data, c->vary.len) != 0
>          || h.crc32 != c->crc32
>          || h.header_start != c->header_start
>          || h.body_start != c->body_start)

The check in question is mostly a safeguard to ensure that 
ngx_file_uniq() check above did it's work properly.  Any specific 
reason to assume it needs to be extended?

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx-devel mailing list