# Fastcgi\_cache replication?

**URL:** <https://www.ruby-forum.com/t/fastcgi-cache-replication/198675>\
**Category:** NGINX\
**Created:** [November 5, 2010, 5:51am UTC](https://www.ruby-forum.com/t/fastcgi-cache-replication/198675 "2010-11-05T05:51:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 5, 2010, 5:51am UTC](https://www.ruby-forum.com/t/fastcgi-cache-replication/198675/1 "2010-11-05T05:51:16Z")

</div>

Hello,

We are successfully using fastcgi\_cache on our PHP application. We  
currently have 5 servers in the farm, which means it currently takes 5x  
as long to build up the cache after each purge/timeout.

Is there anyway to share the cache index/files across servers? I have  
not tried rsync’ing the cache folders between machines but doubt that  
would work, since the files would not exist in the index.

Separately, two lessons we learned.

1. PHP files that contain a redirect with header(“Location: new-url”)  
and immediately exited will not redirect properly when served from the  
cache, due to PHP appending a Content-type. If print some text between  
the header and exit it works fine.

Does not work:  
^A^F^@^A^@?^D^@Status: 301 Moved Permanently^M  
Location:  
[http://store.smartphoneexperts.com/motorola-s9-hd-bluetooth-stereo-headphones/9A115A4142.htm?d=1152^M](http://store.smartphoneexperts.com/motorola-s9-hd-bluetooth-stereo-headphones/9A115A4142.htm?d=1152%5EM)  
Content-type: text/html

Works:  
KEY:  
[httpwww.n95depot.com/motorola-s9-hd-bluetooth-stereo-headphones/9A115A4142.htm](http://httpwww.n95depot.com/motorola-s9-hd-bluetooth-stereo-headphones/9A115A4142.htm)  
^A^F^@^A^@?^D^@Status: 301 Moved Permanently^M  
Location:  
[http://store.smartphoneexperts.com/motorola-s9-hd-bluetooth-stereo-headphones/9A115A4142.htm?d=1152^M](http://store.smartphoneexperts.com/motorola-s9-hd-bluetooth-stereo-headphones/9A115A4142.htm?d=1152%5EM)  
Content-type: text/html^M  
^M  
Redirecting

1. fastcgi\_cache will sometimes cache “blank” pages, likely due to our  
backend acting up. We implemented a cronscript that runs every minute  
and purges cache files \< 512 byes that are not redirects.

Posted at Nginx Forum:

> **[fastcgi\_cache replication?](https://forum.nginx.org/read.php?2,147852,147852#msg-147852)**
>
> Hello, We are successfully using fastcgi\_cache on our PHP application. We currently have 5 servers in the farm, which means it currently takes 5x as long to build up the cache after each purge/timeout. Is there anyway to share the cache index/files...

---

<div class="post-metadata">

**Author:** ![marcusadolfsson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@marcusadolfsson](https://www.ruby-forum.com/u/marcusadolfsson)\
**Post date:** [November 5, 2010, 12:19pm UTC](https://www.ruby-forum.com/t/fastcgi-cache-replication/198675/2 "2010-11-05T12:19:02Z")

</div>

Hello!

On Fri, Nov 05, 2010 at 12:49:52AM -0400, marcusadolfsson wrote:

[…]

> Works:  
> KEY:  
> [httpwww.n95depot.com/motorola-s9-hd-bluetooth-stereo-headphones/9A115A4142.htm](http://httpwww.n95depot.com/motorola-s9-hd-bluetooth-stereo-headphones/9A115A4142.htm)  
> ^A^F^@^A^@?^D^@Status: 301 Moved Permanently^M  
> Location:

[http://store.smartphoneexperts.com/motorola-s9-hd-bluetooth-stereo-headphones/9A115A4142.htm?d=1152^M](http://store.smartphoneexperts.com/motorola-s9-hd-bluetooth-stereo-headphones/9A115A4142.htm?d=1152%5EM)

> Content-type: text/html^M  
> ^M  
> Redirecting

Looks like known problem with caching of 0-sized responses, see  
here for more info and patches:

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

Maxim D.

---

<div class="post-metadata">

**Author:** ![marcusadolfsson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@marcusadolfsson](https://www.ruby-forum.com/u/marcusadolfsson)\
**Post date:** [November 5, 2010, 1:40pm UTC](https://www.ruby-forum.com/t/fastcgi-cache-replication/198675/3 "2010-11-05T13:40:04Z")

</div>

Hello!

On Fri, Nov 05, 2010 at 01:21:55PM +0100, Dennis J. wrote:

> > > the header and exit it works fine.  
> > > ^A^F^@^A^@?^D^@Status: 301 Moved Permanently^M
> 
> The messages referenced in there are almost a year old. Haven’t  
> these patches been included in the main source since then?

No.

Maxim D.

---

<div class="post-metadata">

**Author:** ![marcusadolfsson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@marcusadolfsson](https://www.ruby-forum.com/u/marcusadolfsson)\
**Post date:** [November 5, 2010, 1:23pm UTC](https://www.ruby-forum.com/t/fastcgi-cache-replication/198675/4 "2010-11-05T13:23:06Z")

</div>

On 11/05/2010 12:17 PM, Maxim D. wrote:

> > Location:

[http://store.smartphoneexperts.com/motorola-s9-hd-bluetooth-stereo-headphones/9A115A4142.htm?d=1152^M](http://store.smartphoneexperts.com/motorola-s9-hd-bluetooth-stereo-headphones/9A115A4142.htm?d=1152%5EM)

> > Content-type: text/html^M  
> > ^M  
> > Redirecting
> 
> Looks like known problem with caching of 0-sized responses, see  
> here for more info and patches:
> 
> [[PATCH 0 of 2] cache fixes for empty and stale responses](http://nginx.org/pipermail/nginx-devel/2010-January/000100.html)

The messages referenced in there are almost a year old. Haven’t these  
patches been included in the main source since then?

Regards  
Dennis
