Conditional expires in location

phwaap nginx-forum at forum.nginx.org
Wed Apr 5 22:14:21 UTC 2017


Hi everyone,

I have a generic location that servers many others via rewrite/proxy_pass. 
The generic location calls expires by including a file which disables
caching.  I have new location with its own expiration logic that needs to
bypass this.  What is the best way to do this?

# Generic service.
location = /generic.js {
            fastcgi_pass 'unix:/tmp/generic.socket';
            include fastcgi.conf;
            # only does: expires -1s;
            include expires.conf;   
}

location = /new.js {
        set $new_upstream https://new.lskjdflsj.com/;
        rewrite ^/new.js /generic.js?type=new;
        proxy_pass $new_upstream;
}


I've read that if statements are undesirable in location although that seems
to work.  I've also tried setting an expires variable via a map which also
works. But doesn't this execute for every request?

Zach

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,273434,273434#msg-273434



More information about the nginx mailing list