# Issue with fastcgi\_cache and missing content length / length:0	(chunked transfer encoding)

**URL:** <https://www.ruby-forum.com/t/issue-with-fastcgi-cache-and-missing-content-length-length-0-chunked-transfer-encoding/193931>\
**Category:** NGINX\
**Created:** [August 26, 2010, 6:15pm UTC](https://www.ruby-forum.com/t/issue-with-fastcgi-cache-and-missing-content-length-length-0-chunked-transfer-encoding/193931 "2010-08-26T18:15:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Lohner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f475e1/32.png) [@Thomas\_Lohner](https://www.ruby-forum.com/u/Thomas_Lohner)\
**Post date:** [August 26, 2010, 6:15pm UTC](https://www.ruby-forum.com/t/issue-with-fastcgi-cache-and-missing-content-length-length-0-chunked-transfer-encoding/193931/1 "2010-08-26T18:15:41Z")

</div>

Dear list,

i’m having an issue with cached fastcgi responses with content length 0:

#curl [http://127.0.0.1/lq/aac/iPhone/a3efe0a282dafd](http://127.0.0.1/lq/aac/iPhone/a3efe0a282dafd)  
curl: (18) transfer closed with outstanding read data remaining

#curl -I [http://127.0.0.1/lq/aac/iPhone/a3efe0a282dafd](http://127.0.0.1/lq/aac/iPhone/a3efe0a282dafd)  
HTTP/1.1 302 Moved Temporarily  
Server: nginx/0.8.49  
Date: Thu, 26 Aug 2010 12:27:23 GMT  
Content-Type: audio/aacp  
Connection: close  
Location: [http://xxxxx/stream\_basis\_aac\_lq#4p765no3|0|0|vCubar|nnp|yd](http://xxxxx/stream_basis_aac_lq#4p765no3%7C0%7C0%7CvCubar%7Cnnp%7Cyd)  
X-CACHE: HIT

I understand the Content-Length Header is missing and therefor chunked  
transfer encoding breaks.

This only happens with cached responses and only with fastcgi\_cache.

Everything works fine, if i either disable fastcgi\_cache or if i wrap  
another nginx around my nginx+php-fpm setup with proxy\_cache.

i’ve done quite a bit of research but didn’t find any other solution  
than setting chunked\_transfer\_encoding to off, which effects every  
request.

i’m using nginx/0.8.49 with php-fpm 5.3.3 on gentoo

Is there any other way to fix this? Any thoughts are appreciated.

cheers

–

Thomas Lohner

> **[Thomas Lohner - Geschäftsführer - ScaleCommerce GmbH](https://www.xing.com/profile/Thomas_Lohner)**
>
> Geschäftsführer

> **[SysEleven](https://www.facebook.com/SysEleven)**
>
> SysEleven, Berlin, Germany. 733 likes · 114 were here. Mastering Cloud. Accelerating Business. - https://syseleven.de/impressum

> **[SysEleven | Managed Kubernetes](https://www.syseleven.de/)**
>
> Als Managed Kubernetes und Cloud Service Provider verantwortet SysEleven performante Plattformen, die auch bei unerwarteten Lastspitzen stabil laufen.

---

<div class="post-metadata">

**Author:** ![Thomas\_Lohner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f475e1/32.png) [@Thomas\_Lohner](https://www.ruby-forum.com/u/Thomas_Lohner)\
**Post date:** [August 26, 2010, 6:32pm UTC](https://www.ruby-forum.com/t/issue-with-fastcgi-cache-and-missing-content-length-length-0-chunked-transfer-encoding/193931/2 "2010-08-26T18:32:40Z")

</div>

Hello!

On Thu, Aug 26, 2010 at 06:13:47PM +0200, Thomas Lohner wrote:

> Server: nginx/0.8.49
> 
> effects every request.
> 
> i’m using nginx/0.8.49 with php-fpm 5.3.3 on gentoo
> 
> Is there any other way to fix this? Any thoughts are appreciated.

These patches should resolve your issue:

> **[\[PATCH 0 of 2\] cache fixes for empty and stale responses](http://mailman.nginx.org/pipermail/nginx-devel/2010-January/000100.html)**

> **[\[PATCH 1 of 2\] Cache: fix sending of empty](http://mailman.nginx.org/pipermail/nginx-devel/2010-January/000101.html)**

> **[\[PATCH 2 of 2\] Cache: fix sending of stale responses](http://mailman.nginx.org/pipermail/nginx-devel/2010-January/000102.html)**

Maxim D.

---

<div class="post-metadata">

**Author:** ![Thomas\_Lohner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f475e1/32.png) [@Thomas\_Lohner](https://www.ruby-forum.com/u/Thomas_Lohner)\
**Post date:** [August 27, 2010, 12:22am UTC](https://www.ruby-forum.com/t/issue-with-fastcgi-cache-and-missing-content-length-length-0-chunked-transfer-encoding/193931/3 "2010-08-27T00:22:10Z")

</div>

Hello maybe this php replicement helps to.

> <https://gist.github.com/hmert/505962>

[http://gist.github.com/505962](http://gist.github.com/505962)or add your nginx.conf  
fastcgi\_param CONTENT-LENGTH $content\_length;

–  
HÃ¼seyin Mert  
[http://www.hmert.com](http://www.hmert.com)
