use real file cache length, this fixes cache size counting for responses

without "Content-Length" header and 304 responses.
This commit is contained in:
Igor Sysoev 2009-10-07 12:55:58 +00:00
parent 9e54633645
commit 136dd8d1e6
2 changed files with 5 additions and 8 deletions

View File

@ -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;

View File

@ -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 {