# How to define dynamic proxy\_cache\_path directory

**URL:** <https://www.ruby-forum.com/t/how-to-define-dynamic-proxy-cache-path-directory/238608>\
**Category:** NGINX\
**Created:** [January 20, 2014, 9:44am UTC](https://www.ruby-forum.com/t/how-to-define-dynamic-proxy-cache-path-directory/238608 "2014-01-20T09:44:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [January 20, 2014, 9:44am UTC](https://www.ruby-forum.com/t/how-to-define-dynamic-proxy-cache-path-directory/238608/1 "2014-01-20T09:44:50Z")

</div>

Hello,

I use Nginx/1.4.4 as a reverse proxy caching server for multiple sites.  
So  
far I have been using same proxy\_cache\_path for all sites. Now I want to  
use separate cache path for all sites.

Is there anyway to make proxy\_cache\_path dynamic i.e. using some  
variable  
in proxy\_cache\_path like $host ?

Thanks,  
Makailol

---

<div class="post-metadata">

**Author:** ![Makailol\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71c47a/32.png) [@Makailol\_C](https://www.ruby-forum.com/u/Makailol_C)\
**Post date:** [January 20, 2014, 1:57pm UTC](https://www.ruby-forum.com/t/how-to-define-dynamic-proxy-cache-path-directory/238608/2 "2014-01-20T13:57:16Z")

</div>

Hello!

On Mon, Jan 20, 2014 at 02:14:26PM +0530, Makailol C. wrote:

> Hello,
> 
> I use Nginx/1.4.4 as a reverse proxy caching server for multiple sites. So  
> far I have been using same proxy\_cache\_path for all sites. Now I want to  
> use separate cache path for all sites.
> 
> Is there anyway to make proxy\_cache\_path dynamic i.e. using some variable  
> in proxy\_cache\_path like $host ?

No, proxy\_cache\_path must be known without a request for cache  
loader and cache manager to work. Therefore it’s not possible to  
use variables in proxy\_cache\_path, you have to explicitly define  
all caches you want to use.

–  
Maxim D.  
[http://nginx.org/](http://nginx.org/)

---

<div class="post-metadata">

**Author:** ![Makailol\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71c47a/32.png) [@Makailol\_C](https://www.ruby-forum.com/u/Makailol_C)\
**Post date:** [January 21, 2014, 9:30am UTC](https://www.ruby-forum.com/t/how-to-define-dynamic-proxy-cache-path-directory/238608/3 "2014-01-21T09:30:01Z")

</div>

Hello Maxim,

Thanks to reply on this .

If we have single cache path (directory) for multiple sites, is there  
some  
way to clear(purge) all cached pages for particular site?

Regards,  
Makailol
