# Re: Simple question about proxy cache

**URL:** <https://www.ruby-forum.com/t/re-simple-question-about-proxy-cache/227654>\
**Category:** NGINX\
**Created:** [March 22, 2013, 1:24pm UTC](https://www.ruby-forum.com/t/re-simple-question-about-proxy-cache/227654 "2013-03-22T13:24:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [March 22, 2013, 1:24pm UTC](https://www.ruby-forum.com/t/re-simple-question-about-proxy-cache/227654/1 "2013-03-22T13:24:21Z")

</div>

On 22/03/13 11:43, Maxim D. wrote:

> > level instead. If I do this, though, then EVERY request for that server  
> > ends up being logged, even if there is no cache in force for the request  
> > location (i.e., the location has either ‘proxy\_cache off’ or no  
> > proxy\_cache definition. Is there a way I can configure things so that  
> > the only requests which are logged are ones from locations where a proxy  
> > cache is in force?  
> > You _can_ repeat acces\_log in every location. If nginx complains -  
> > you did something wrong (tried to repeat log\_format?).

Thanks Maxim, that’s exactly what I did do, as my follow-up post  
mentioned. All sorted now and working wonderfully. There is one other  
thing, though…At the moment, I have two location blocks with identical  
content, in order to match two different patterns. One matches all URLs  
starting with certain strings, e.g.

location ~ ^/(abc|def){

The other is an exact match for the top level page:

location = /{

Ideally I would like to use a single pattern which combined both. I  
thought to use regex end markers instead of the exact match, but I’m not  
sure if it’s syntactically correct (and this is a very busy server i  
don’t want to mess about with too much experimenting). So would  
something like this work?

location ~ (^/abc|^/def/|^/$)

John

John

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [March 22, 2013, 3:12pm UTC](https://www.ruby-forum.com/t/re-simple-question-about-proxy-cache/227654/2 "2013-03-22T15:12:30Z")

</div>

Hello!

On Fri, Mar 22, 2013 at 12:24:21PM +0000, John M. wrote:

> > > rightly complains about duplication). So I have to define it at a server
> 
> location = /{
> 
> Ideally I would like to use a single pattern which combined both. I  
> thought to use regex end markers instead of the exact match, but I’m not  
> sure if it’s syntactically correct (and this is a very busy server i  
> don’t want to mess about with too much experimenting). So would  
> something like this work?
> 
> location ~ (^/abc|^/def/|^/$)

This looks like valid regular expression (try pcretest if unsure),  
but from maintainability point of view I would recommend to use  
multiple normal prefix or exact match locations instead of trying to  
combine them into a single regexp.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**
