broser cache expires when reverse proxy use

n1xman nginx-forum at nginx.us
Fri Jun 24 21:19:26 MSD 2011


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: http://forum.nginx.org/read.php?2,209723,209723#msg-209723




More information about the nginx mailing list