mirror of
https://github.com/nginx/nginx.git
synced 2024-12-01 03:17:17 +08:00
use real file cache length, this fixes cache size counting for responses
without "Content-Length" header and 304 responses.
This commit is contained in:
parent
9e54633645
commit
136dd8d1e6
@ -692,7 +692,7 @@ ngx_http_file_cache_set_header(ngx_http_request_t *r, u_char *buf)
|
||||
void
|
||||
ngx_http_file_cache_update(ngx_http_request_t *r, ngx_temp_file_t *tf)
|
||||
{
|
||||
off_t size;
|
||||
off_t size, length;
|
||||
ngx_int_t rc;
|
||||
ngx_file_uniq_t uniq;
|
||||
ngx_file_info_t fi;
|
||||
@ -714,6 +714,7 @@ ngx_http_file_cache_update(ngx_http_request_t *r, ngx_temp_file_t *tf)
|
||||
cache = c->file_cache;
|
||||
|
||||
uniq = 0;
|
||||
length = 0;
|
||||
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"http file cache rename: \"%s\" to \"%s\"",
|
||||
@ -738,10 +739,11 @@ ngx_http_file_cache_update(ngx_http_request_t *r, ngx_temp_file_t *tf)
|
||||
|
||||
} else {
|
||||
uniq = ngx_file_uniq(&fi);
|
||||
length = ngx_file_size(&fi);
|
||||
}
|
||||
}
|
||||
|
||||
size = (c->length + cache->bsize - 1) / cache->bsize;
|
||||
size = (length + cache->bsize - 1) / cache->bsize;
|
||||
|
||||
ngx_shmtx_lock(&cache->shpool->mutex);
|
||||
|
||||
@ -751,7 +753,7 @@ ngx_http_file_cache_update(ngx_http_request_t *r, ngx_temp_file_t *tf)
|
||||
|
||||
size = size - (c->node->length + cache->bsize - 1) / cache->bsize;
|
||||
|
||||
c->node->length = c->length;
|
||||
c->node->length = length;
|
||||
|
||||
cache->sh->size += size;
|
||||
|
||||
|
@ -2098,11 +2098,6 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
r->cache->date = now;
|
||||
r->cache->body_start = (u_short) (u->buffer.pos - u->buffer.start);
|
||||
|
||||
if (r->headers_out.content_length_n != -1) {
|
||||
r->cache->length = r->cache->body_start
|
||||
+ r->headers_out.content_length_n;
|
||||
}
|
||||
|
||||
ngx_http_file_cache_set_header(r, u->buffer.start);
|
||||
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user