Welcome! Log In Create A New Profile

Advanced

Re: cached files with wrong size

Maxim Dounin
October 19, 2012 06:34AM
Hello!

On Fri, Oct 19, 2012 at 11:10:20AM +0300, Anatoli Marinov wrote:

> *Hello colleagues,
> I have some troubles when caching (with proxy cache) some objects
> which don't
> have content-length header. It happens with gzipped .js or .css
> files. Usually
> these files don't have content-length because its size is not known
> when headers
> are sent.
>
> If the connection between proxy server and origin behind it
> disconnects during
> file transfer the file will be checked if it has correct size only if
> content-length exists. Otherwise the file will be cached normally even it
> does not have correct size.
>
> In this case corrupted file will be sent to the browser and probably
> it will break normal behaviour of a served website.
> Do you know a solution for such kind of issues?*

As soon as the connection is closed uncleanly (i.e. was reset or
times out), there should be no problem with proxy_cache: nginx
will detect there is an error and won't cache the response.

If the connection is closed cleanly (e.g. your OS does a clean
connection close on a behalf of an unexpectedly terminated app, or
an unexpected connection close is hidden behind another proxy
layer), there is a problem though: one can't detect if a response
is complete with HTTP/1.0 without Content-Length present.

With HTTP/1.1 situation is a bit improved, as it has
chunked transfer-coding. Though as of now nginx doesn't try to
take it into account when caching files even if HTTP/1.1 to
backends is activated using proxy_http_version directive.

I've already suggested a way to improve things here:
http://mailman.nginx.org/pipermail/nginx-devel/2012-September/002699.html

It should improve things with HTTP/1.1 used, though no one tried
to actually do it yet, and I don't have time to dig into this
right now.


--
Maxim Dounin
http://nginx.com/support.html

p.s. Please don't use html to post here. Thanks.

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

cached files with wrong size

toli 1152 October 19, 2012 04:12AM

Re: cached files with wrong size

Maxim Dounin 780 October 19, 2012 06:34AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 179
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready