# Broser cache expires when reverse proxy use

**URL:** <https://www.ruby-forum.com/t/broser-cache-expires-when-reverse-proxy-use/208700>\
**Category:** NGINX\
**Created:** [June 24, 2011, 7:19pm UTC](https://www.ruby-forum.com/t/broser-cache-expires-when-reverse-proxy-use/208700 "2011-06-24T19:19:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [June 24, 2011, 7:19pm UTC](https://www.ruby-forum.com/t/broser-cache-expires-when-reverse-proxy-use/208700/1 "2011-06-24T19:19:59Z")

</div>

Hi,

We need to cache images while reverse proxy with the following  
settings.

```
    location /foo {
    proxy_pass http://www.example.com/foo;
    proxy_set_header X-Real-IP $remote_addr;
     if ($request_uri ~* \.(jpg|gif)$) {
    expires 60d;
    add_header Cache-Control private;
    }
    ....

```

This is working if we use it without reverse proxy. I have tried  
$upstream\_http\_request\_uri with no luck.

I have tried the following as well.

```
    location /foo/images {
    proxy_pass http://www.example.com;
    expires 60d;
    add_header Cache-Control private;
    }

```

But it matches images in /images directory not in any other directory  
within the reverse proxy domain.

Please advice how do we properly set browser cache expires while we do  
reverse proxy.

Thanks in advance

Posted at Nginx Forum:

> **[broser cache expires when reverse proxy use](https://forum.nginx.org/read.php?2,209723,209723#msg-209723)**
>
> Hi, We need to cache images while reverse proxy with the following settings. location /foo { proxy\_pass http://www.example.com/foo; proxy\_set\_header X-Real-IP $remote\_addr; if ($request\_uri ~\* \\.(jpg|gif)$) {
