# Content-Length compared to actual size before caching

**URL:** <https://www.ruby-forum.com/t/content-length-compared-to-actual-size-before-caching/217726>\
**Category:** NGINX\
**Created:** [March 10, 2012, 1:15am UTC](https://www.ruby-forum.com/t/content-length-compared-to-actual-size-before-caching/217726 "2012-03-10T01:15:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 10, 2012, 1:15am UTC](https://www.ruby-forum.com/t/content-length-compared-to-actual-size-before-caching/217726/1 "2012-03-10T01:15:15Z")

</div>

If my upstream goes away I get an error

upstream prematurely closed connection while reading response header  
from upstream

or

recv() failed (104: Connection reset by peer) while reading response  
header from upstream

unfortunately, this still gives me a 200 code and this return is entered  
incomplete into my memcache. Is there some way to get the size of the  
current request from proxy\_pass so I can compare it to the  
Content\_Length and discard it if it’s mismatched?

Ideally the system wouldn’t tag incomplete responses as 200 OK, so they  
wouldn’t end up as short returns in my memcache for their cache  
duration.

Posted at Nginx Forum:

> **[Content-Length compared to actual size before caching](https://forum.nginx.org/read.php?2,223690,223690#msg-223690)**
>
> If my upstream goes away I get an error upstream prematurely closed connection while reading response header from upstream or recv() failed (104: Connection reset by peer) while reading response header from upstream unfortunately, this
