# Understanding break and add\_header combo

**URL:** <https://www.ruby-forum.com/t/understanding-break-and-add-header-combo/228673>\
**Category:** NGINX\
**Created:** [May 2, 2013, 5:53pm UTC](https://www.ruby-forum.com/t/understanding-break-and-add-header-combo/228673 "2013-05-02T17:53:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flarik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@flarik](https://www.ruby-forum.com/u/flarik)\
**Post date:** [May 2, 2013, 5:53pm UTC](https://www.ruby-forum.com/t/understanding-break-and-add-header-combo/228673/1 "2013-05-02T17:53:41Z")

</div>

Hello,

I’m trying to undestand the break; statement in combination with  
add\_header  
combo, on the wiki it says the following:

“Completes the current set of rules. Continue processing within the  
current  
location block but do not process any more rewrite directives.”

I read this as everything that has todo with the HttpRewriteModule will  
not  
be processed any more after this statement. I have the following piece  
of  
config for a rails app:

server {

listen 80;

server\_name x;

root /var/www/vhost/x/current/public;  
passenger\_enabled on;

location ~ ^/assets/ {  
expires 1y;  
add\_header Cache-Control public;

```
# Some browsers still send conditional-GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.
add_header Last-Modified "";
add_header ETag "";
break;

```

}

# Webfonts (they are in /assets)

location ~\* .(ttf|ttc|otf|eot|woff)$ {  
add\_header Access-Control-Allow-Methods GET,OPTIONS;  
add\_header Access-Control-Allow-Headers \*;  
add\_header Access-Control-Allow-Origin \*;  
}

}

Now the add\_header stuff for webfonts is never set, and I do not  
understand  
why break has a part in this. When I remove break; it works,  
when i put the font location stuff before location ~^/assets/ it also  
works.

Hope someone can shine some light on this.

Kind Regards,

Frodo L.

Posted at Nginx Forum:

> **[understanding break and add\_header combo](https://forum.nginx.org/read.php?2,238797,238797#msg-238797)**
>
> Hello, I'm trying to undestand the break; statement in combination with add\_header combo, on the wiki it says the following: "Completes the current set of rules. Continue processing within the current location block but do not process any more...

---

<div class="post-metadata">

**Author:** ![flarik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@flarik](https://www.ruby-forum.com/u/flarik)\
**Post date:** [May 2, 2013, 10:31pm UTC](https://www.ruby-forum.com/t/understanding-break-and-add-header-combo/228673/2 "2013-05-02T22:31:15Z")

</div>

On Thu, May 02, 2013 at 11:53:12AM -0400, flarik wrote:

Hi there,

> location ~ ^/assets/ {

> location ~\* .(ttf|ttc|otf|eot|woff)$ {

> Now the add\_header stuff for webfonts is never set, and I do not understand  
> why break has a part in this. When I remove break; it works,  
> when i put the font location stuff before location ~^/assets/ it also  
> works.

What request do you make? What response do you get? What response do  
you expect?

In nginx, one request is handled in one location. So I expect that no  
more  
than one set of add\_header directives will apply. And as you only show  
regex locations, if the first one matches then it is the one that is  
used.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![flarik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@flarik](https://www.ruby-forum.com/u/flarik)\
**Post date:** [May 3, 2013, 10:01am UTC](https://www.ruby-forum.com/t/understanding-break-and-add-header-combo/228673/3 "2013-05-03T10:01:21Z")

</div>

## Francis D. Wrote:

Hello Francis, thanks for your response.

> In nginx, one request is handled in one location. So I expect that no  
> more  
> than one set of add\_header directives will apply. And as you only show  
> regex locations, if the first one matches then it is the one that is  
> used.

Ah, that makes sense, thanks!

Regards,

Frodo

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,238797,238808#msg-238808](http://forum.nginx.org/read.php?2,238797,238808#msg-238808)
