From da2b2cf1e039630cec84e8b67d99c4d578361b0d Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Thu, 22 Dec 2016 14:25:34 +0300 Subject: Cache: support for stale-while-revalidate and stale-if-error. Previously, there was no way to enable the proxy_cache_use_stale behavior by reading the backend response. Now, stale-while-revalidate and stale-if-error Cache-Control extensions (RFC 5861) are supported. They specify, how long a stale response can be used when a cache entry is being updated, or in case of an error. --- src/http/ngx_http_cache.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/http/ngx_http_cache.h') diff --git a/src/http/ngx_http_cache.h b/src/http/ngx_http_cache.h index 4075f3dec..d253812f6 100644 --- a/src/http/ngx_http_cache.h +++ b/src/http/ngx_http_cache.h @@ -27,7 +27,7 @@ #define NGX_HTTP_CACHE_ETAG_LEN 42 #define NGX_HTTP_CACHE_VARY_LEN 42 -#define NGX_HTTP_CACHE_VERSION 3 +#define NGX_HTTP_CACHE_VERSION 4 typedef struct { @@ -71,6 +71,8 @@ struct ngx_http_cache_s { ngx_file_uniq_t uniq; time_t valid_sec; + time_t updating_sec; + time_t error_sec; time_t last_modified; time_t date; @@ -114,12 +116,17 @@ struct ngx_http_cache_s { unsigned purged:1; unsigned reading:1; unsigned secondary:1; + + unsigned stale_updating:1; + unsigned stale_error:1; }; typedef struct { ngx_uint_t version; time_t valid_sec; + time_t updating_sec; + time_t error_sec; time_t last_modified; time_t date; uint32_t crc32; -- cgit