# Serve different set of cache conditionally

**URL:** <https://www.ruby-forum.com/t/serve-different-set-of-cache-conditionally/225313>\
**Category:** NGINX\
**Created:** [December 29, 2012, 12:24am UTC](https://www.ruby-forum.com/t/serve-different-set-of-cache-conditionally/225313 "2012-12-29T00:24:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [December 29, 2012, 12:24am UTC](https://www.ruby-forum.com/t/serve-different-set-of-cache-conditionally/225313/1 "2012-12-29T00:24:34Z")

</div>

Hi All,

I would like to know if I can configure nginx to utilise different set  
of  
cache zone conditionally.

For example

- if the user-agent is a mobile device then use proxy\_cache zone called  
“mobile\_proxy\_zone”
- if $http\_cookie contains the word “semi-static” then use proxy\_cache  
zone  
called “semistatic\_proxy\_zone”
- if user IP address is 8.8.0.0/16 then use proxy\_cache zone called  
“gws\_internal\_zone”
- Serve the rest using proxy\_cache zone default\_zone

At this point, I don’t mind having the rules as first hit first serve (  
ie  
if it matched user-agent then just use mobile\_proxy\_zone even when the  
semi-static is present on the $http\_cookie )

Is this do able ?  
Can we specify the proxy zone dynamically ?

Regards,  
Rianto Wahyudi

Posted at Nginx Forum:

> **[Serve different set of cache conditionally](https://forum.nginx.org/read.php?2,234555,234555#msg-234555)**
>
> Hi All, I would like to know if I can configure nginx to utilise different set of cache zone conditionally. For example - if the user-agent is a mobile device then use proxy\_cache zone called "mobile\_proxy\_zone" - if $http\_cookie contains...
