aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_file_cache.c
diff options
context:
space:
mode:
authorSergey Kandaurov <pluknet@nginx.com>2020-09-09 19:26:27 +0300
committerSergey Kandaurov <pluknet@nginx.com>2020-09-09 19:26:27 +0300
commitdc1b14126e0a7a45018d95b149ebdb29985f18f1 (patch)
tree5869427b638702bc2b96eb23e647719d699ef347 /src/http/ngx_http_file_cache.c
parented0b19cdd4a9118cf8795ba2cf0a56684624bb41 (diff)
downloadnginx-dc1b14126e0a7a45018d95b149ebdb29985f18f1.tar.gz
nginx-dc1b14126e0a7a45018d95b149ebdb29985f18f1.zip
Cache: keep c->body_start when Vary changes (ticket #2029).
If the variant hash doesn't match one we used as a secondary cache key, we switch back to the original key. In this case, c->body_start was kept updated from an existing cache node overwriting the new response value. After file cache update, it led to discrepancy between a cache node and cache file seen as critical errors "file cache .. has too long header".
Diffstat (limited to 'src/http/ngx_http_file_cache.c')
-rw-r--r--src/http/ngx_http_file_cache.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c
index 7a5b4ca5b..c40093bca 100644
--- a/src/http/ngx_http_file_cache.c
+++ b/src/http/ngx_http_file_cache.c
@@ -854,7 +854,7 @@ ngx_http_file_cache_exists(ngx_http_file_cache_t *cache, ngx_http_cache_t *c)
if (fcn->exists || fcn->uses >= c->min_uses) {
c->exists = fcn->exists;
- if (fcn->body_start) {
+ if (fcn->body_start && !c->update_variant) {
c->body_start = fcn->body_start;
}
@@ -1339,6 +1339,7 @@ ngx_http_file_cache_update_variant(ngx_http_request_t *r, ngx_http_cache_t *c)
ngx_shmtx_unlock(&cache->shpool->mutex);
c->file.name.len = 0;
+ c->update_variant = 1;
ngx_memcpy(c->key, c->main, NGX_HTTP_CACHE_KEY_LEN);