# Sync multi nginx (persistent) caching proxy for one(or more) app server

**URL:** <https://www.ruby-forum.com/t/sync-multi-nginx-persistent-caching-proxy-for-one-or-more-app-server/210189>\
**Category:** NGINX\
**Created:** [August 2, 2011, 4:53am UTC](https://www.ruby-forum.com/t/sync-multi-nginx-persistent-caching-proxy-for-one-or-more-app-server/210189 "2011-08-02T04:53:24Z")\
**Posts on this page:** 4\
**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:** [August 2, 2011, 4:53am UTC](https://www.ruby-forum.com/t/sync-multi-nginx-persistent-caching-proxy-for-one-or-more-app-server/210189/1 "2011-08-02T04:53:24Z")

</div>

Hi,

I am a newbie Nginx user, so bear with me here 😉

I want to setup multiple (identical) caching proxy in front of my app  
server.

Basically - Load balancer - multiple nginx caching proxy - app  
server(s)

So I have two questions:

1. How do I make the cache persistent (across nginx restart)?  
Wiki says that keys and metadata are stored in shared memory, does that  
mean it’s not possible to save cache?

2. How do I sync the caches on different nginx, so that same URL request  
does not hit app server multiple times.  
Can I use something like rsync?

Thanks a lot!

Posted at Nginx Forum:

> **[Sync multi nginx (persistent) caching proxy for one(or more) app server](https://forum.nginx.org/read.php?2,213225,213225#msg-213225)**
>
> Hi, I am a newbie Nginx user, so bear with me here ;-) I want to setup multiple (identical) caching proxy in front of my app server. Basically - Load balancer - multiple nginx caching proxy - app server(s) So I have two questions:

---

<div class="post-metadata">

**Author:** ![lennydizzy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8491ac/32.png) [@lennydizzy](https://www.ruby-forum.com/u/lennydizzy)\
**Post date:** [August 2, 2011, 5:24am UTC](https://www.ruby-forum.com/t/sync-multi-nginx-persistent-caching-proxy-for-one-or-more-app-server/210189/2 "2011-08-02T05:24:16Z")

</div>

lookup proxy\_cache\_path. Cache is stored in a folder structure then.

As its filebased I persume rsync would work, although I am not sure of  
the  
exact implementation in nginx it may not be picked up by the cache  
loaded  
unless you reload.

---

<div class="post-metadata">

**Author:** ![lennydizzy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8491ac/32.png) [@lennydizzy](https://www.ruby-forum.com/u/lennydizzy)\
**Post date:** [August 2, 2011, 6:40am UTC](https://www.ruby-forum.com/t/sync-multi-nginx-persistent-caching-proxy-for-one-or-more-app-server/210189/3 "2011-08-02T06:40:05Z")

</div>

On Mon, Aug 01, 2011 at 10:43:53PM -0400, lennydizzy wrote:

> So I have two questions:
> 
> 1. How do I make the cache persistent (across nginx restart)?  
> Wiki says that keys and metadata are stored in shared memory, does that  
> mean it’s not possible to save cache?

The cache is persistent. Keys and metadata are loaded gracefully (I  
hope)  
from disk on nginx start.

> 1. How do I sync the caches on different nginx, so that same URL request  
> does not hit app server multiple times.  
> Can I use something like rsync?

No, currently it’s not possible.

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![lennydizzy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8491ac/32.png) [@lennydizzy](https://www.ruby-forum.com/u/lennydizzy)\
**Post date:** [August 2, 2011, 4:06pm UTC](https://www.ruby-forum.com/t/sync-multi-nginx-persistent-caching-proxy-for-one-or-more-app-server/210189/4 "2011-08-02T16:06:28Z")

</div>

On 8/1/11 10:43 PM, “lennydizzy” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 1. How do I sync the caches on different nginx, so that same URL request  
> does not hit app server multiple times.  
> Can I use something like rsync?

You could use memc and srcache (nginx modules) to share the cache in  
memcache.

–  
Brian A.
