# Location support for multiple URLs

**URL:** <https://www.ruby-forum.com/t/location-support-for-multiple-urls/228022>\
**Category:** NGINX\
**Created:** [April 6, 2013, 5:35pm UTC](https://www.ruby-forum.com/t/location-support-for-multiple-urls/228022 "2013-04-06T17:35:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Typlo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@Typlo](https://www.ruby-forum.com/u/Typlo)\
**Post date:** [April 6, 2013, 5:35pm UTC](https://www.ruby-forum.com/t/location-support-for-multiple-urls/228022/1 "2013-04-06T17:35:37Z")

</div>

Hello,  
I would like to use the FastCGI cache feature of nginx for my web  
application. But I need to use it only for a set of URL.

I would like to use it for the following locations:

[Domain.com](http://domain.com/index.php?act=detail&ID=)[ANY ID HERE]

Example:  
[http://domain.com/index.php?act=detail&id=o2Zimg](http://domain.com/index.php?act=detail&id=o2Zimg)

And so on.  
What should I place in the location directive to cache only those URLs?  
I can’t figure it out on the nginx wiki.

Also, I would like to replace the Cache Control and Pragma headers set  
by my PHP application, can I use add\_headers directive? Or I would have  
to add a 3rd party module, like more\_http\_headers? I use nginx from  
PPA(Ubuntu), so for adding more\_http\_headers I would have to build it 😕

Greetings from Antarctica.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Typlo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@Typlo](https://www.ruby-forum.com/u/Typlo)\
**Post date:** [May 9, 2013, 5:33am UTC](https://www.ruby-forum.com/t/location-support-for-multiple-urls/228022/2 "2013-05-09T05:33:48Z")

</div>

On Sun, Apr 7, 2013 at 12:34 AM, Typlo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> And so on.  
> What should I place in the location directive to cache only those URLs?  
> I can’t figure it out on the nginx wiki.
> 
> Also, I would like to replace the Cache Control and Pragma headers set by my PHP  
> application, can I use add\_headers directive? Or I would have to add a 3rd party  
> module, like more\_http\_headers? I use nginx from PPA(Ubuntu), so for adding  
> more\_http\_headers I would have to build it 😕

There’s good reason people build urls like  
[http://domain.com/detail/2Zimg](http://domain.com/detail/2Zimg) instead of what you’re using (namely,  
it’s difficult to configure its caching).

(this email probably doesn’t help, yes)

–  
O\< ascii ribbon campaign - stop html mail - [www.asciiribbon.org](http://www.asciiribbon.org)

---

<div class="post-metadata">

**Author:** ![Typlo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@Typlo](https://www.ruby-forum.com/u/Typlo)\
**Post date:** [May 9, 2013, 3:10pm UTC](https://www.ruby-forum.com/t/location-support-for-multiple-urls/228022/3 "2013-05-09T15:10:27Z")

</div>

You can do that.

At the http level set a map directive like:

map $arg\_act$arg\_ID $no\_cache {  
default 1;  
~\*detail[[:alnum:]]+ 0; # assuming the ID is alphanumeric  
}

Then add:

fastcgi\_cache\_bypass $no\_cache;  
fastcgi\_no\_cache $no\_cache;

to your FastCGI cache configuration.

As per the headers I don’t quite understand what you want to do. Do you  
want the FastCGI cache to ignore the Cache-Control headers set by the  
application?

----appa
