# Adding expires but not show up in headers

**URL:** <https://www.ruby-forum.com/t/adding-expires-but-not-show-up-in-headers/235385>\
**Category:** NGINX\
**Created:** [June 19, 2013, 6:04am UTC](https://www.ruby-forum.com/t/adding-expires-but-not-show-up-in-headers/235385 "2013-06-19T06:04:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [June 19, 2013, 6:04am UTC](https://www.ruby-forum.com/t/adding-expires-but-not-show-up-in-headers/235385/1 "2013-06-19T06:04:33Z")

</div>

Hi,

I added a expires as follow:

location ~ ^/images/ {  
root /var/www  
expires max;  
}

if I do a curl -I [http://localhost/images/sample.jpg](http://localhost/images/sample.jpg), I got following  
headers, but can not find the “Expires” in the headers, what I did wrong  
here? Thanks.

HTTP/1.1 200 OK  
Server: nginx/1.4.1  
Date: Wed, 19 Jun 2013 03:52:13 GMT  
Content-Type: image/jpeg  
Content-Length: 17584  
Last-Modified: Wed, 19 Jun 2013 02:12:31 GMT  
Connection: keep-alive  
ETag: “51c1138f-44b0”  
Accept-Ranges: bytes

Posted at Nginx Forum:

> **[adding expires but not show up in headers](https://forum.nginx.org/read.php?2,240201,240201#msg-240201)**
>
> Hi, I added a expires as follow: location ~ ^/images/ { root /var/www expires max; } if I do a curl -I http://localhost/images/sample.jpg, I got following headers, but can not find the "Expires" in the header

---

<div class="post-metadata">

**Author:** ![angelochen960](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@angelochen960](https://www.ruby-forum.com/u/angelochen960)\
**Post date:** [June 19, 2013, 10:05am UTC](https://www.ruby-forum.com/t/adding-expires-but-not-show-up-in-headers/235385/2 "2013-06-19T10:05:56Z")

</div>

On Wed, Jun 19, 2013 at 12:03:35AM -0400, angelochen960 wrote:

Hi there,

> location ~ ^/images/ {  
> root /var/www  
> expires max;  
> }
> 
> if I do a curl -I [http://localhost/images/sample.jpg](http://localhost/images/sample.jpg), I got following  
> headers, but can not find the “Expires” in the headers, what I did wrong  
> here? Thanks.

What other “location” lines do you have for this server? Only one of  
them will be used for the request /images/sample.jpg.

## f

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

---

<div class="post-metadata">

**Author:** ![angelochen960](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@angelochen960](https://www.ruby-forum.com/u/angelochen960)\
**Post date:** [June 19, 2013, 11:29am UTC](https://www.ruby-forum.com/t/adding-expires-but-not-show-up-in-headers/235385/3 "2013-06-19T11:29:29Z")

</div>

there is another one, but more specific, but it comes before location ~  
^/images/:

location ~ “^(/images/)(\d{1})/(\d{2})/(.\*.jpg$)” {  
}

Posted at Nginx Forum:

> **[Re: adding expires but not show up in headers](https://forum.nginx.org/read.php?2,240201,240205#msg-240205)**
>
> Hi, I added a expires as follow: location ~ ^/images/ { root /var/www expires max; } if I do a curl -I http://localhost/images/sample.jpg, I got following headers, but can not find the "Expires" in the header

---

<div class="post-metadata">

**Author:** ![angelochen960](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@angelochen960](https://www.ruby-forum.com/u/angelochen960)\
**Post date:** [June 19, 2013, 11:32am UTC](https://www.ruby-forum.com/t/adding-expires-but-not-show-up-in-headers/235385/4 "2013-06-19T11:32:24Z")

</div>

there is one before that:  
location ~ “^(/images/)(\d{1})/(\d{2})/(.\*.jpg$)” {

}

Posted at Nginx Forum:

> **[Re: adding expires but not show up in headers](https://forum.nginx.org/read.php?2,240201,240206#msg-240206)**
>
> Hi, I added a expires as follow: location ~ ^/images/ { root /var/www expires max; } if I do a curl -I http://localhost/images/sample.jpg, I got following headers, but can not find the "Expires" in the header

---

<div class="post-metadata">

**Author:** ![angelochen960](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@angelochen960](https://www.ruby-forum.com/u/angelochen960)\
**Post date:** [June 19, 2013, 12:19pm UTC](https://www.ruby-forum.com/t/adding-expires-but-not-show-up-in-headers/235385/5 "2013-06-19T12:19:09Z")

</div>

Hello!

On Wed, Jun 19, 2013 at 05:28:51AM -0400, angelochen960 wrote:

> there is another one, but more specific, but it comes before location ~  
> ^/images/:
> 
> location ~ “^(/images/)(\d{1})/(\d{2})/(.\*.jpg$)” {  
> }

There is no such thing as “more specific” when you are talking  
about regular expressions. First match wins. See here for  
details:

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#location)**
>
> This directive appeared in version 1.11.8.

–  
Maxim D.

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

---

<div class="post-metadata">

**Author:** ![angelochen960](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@angelochen960](https://www.ruby-forum.com/u/angelochen960)\
**Post date:** [June 19, 2013, 1:04pm UTC](https://www.ruby-forum.com/t/adding-expires-but-not-show-up-in-headers/235385/6 "2013-06-19T13:04:08Z")

</div>

On Wed, Jun 19, 2013 at 05:28:51AM -0400, angelochen960 wrote:

Hi there,

> there is another one, but more specific, but it comes before location ~  
> ^/images/:
> 
> location ~ “^(/images/)(\d{1})/(\d{2})/(.\*.jpg$)” {  
> }

If the only two “location” blocks in your server are:

location ~ “^(/images/)(\d{1})/(\d{2})/(.\*.jpg$)” {  
location ~ ^/images/ {

then the request for /images/sample.jpg will be handled in the second  
one.

Which is not what you reported seeing.

## f

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

---

<div class="post-metadata">

**Author:** ![angelochen960](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@angelochen960](https://www.ruby-forum.com/u/angelochen960)\
**Post date:** [June 19, 2013, 12:40pm UTC](https://www.ruby-forum.com/t/adding-expires-but-not-show-up-in-headers/235385/7 "2013-06-19T12:40:46Z")

</div>

You are right, thanks to Francis too for giving me the right direction  
to  
look for the problem, it’s really the other location that should have  
the  
expires set as well, thanks.

Posted at Nginx Forum:

> **[Re: adding expires but not show up in headers (SOLVED)](https://forum.nginx.org/read.php?2,240201,240208#msg-240208)**
>
> Hi, I added a expires as follow: location ~ ^/images/ { root /var/www expires max; } if I do a curl -I http://localhost/images/sample.jpg, I got following headers, but can not find the "Expires" in the header

---

<div class="post-metadata">

**Author:** ![angelochen960](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@angelochen960](https://www.ruby-forum.com/u/angelochen960)\
**Post date:** [June 28, 2013, 7:19am UTC](https://www.ruby-forum.com/t/adding-expires-but-not-show-up-in-headers/235385/8 "2013-06-28T07:19:40Z")

</div>

Read news update here daily. We introduce new gadgets.  
[Event Planning](http://viktorix.com/).

Posted at Nginx Forum:

> **[Re: adding expires but not show up in headers](https://forum.nginx.org/read.php?2,240201,240401#msg-240401)**
>
> Hi, I added a expires as follow: location ~ ^/images/ { root /var/www expires max; } if I do a curl -I http://localhost/images/sample.jpg, I got following headers, but can not find the "Expires" in the header
