Welcome! Log In Create A New Profile

Advanced

Re: Setting cache parameters via if directives

Jeff Mitchell
January 29, 2011 11:10AM
On 01/29/2011 03:19 AM, Jeff Mitchell wrote:
> On 01/28/2011 10:55 AM, Ryan Malayter wrote:
>> I do something similar using the conditinal setting of variables
>> inside the if block to set Cache-Control values, perhaps you can use a
>> similar method to set the values of proxy_cache_valid. Since setting
>> variables is one of the few "safe" things to do inside an if block,
>> and most directives can take variables as agurments, it is generally
>> useful.
>>
>> location / {
>> set $mycc = "private, max-age=0";
>>
>> if ($foo = "bar") {
>> set $mycc = "public, max-age=3600"
>> }
>>
>> proxy_pass http://backend;
>> add_header Cache-Control $mycc;
>> }
>
> Great idea, thank you.

Unfortunately, this doesn't work:

set $cachevalidval "60m";
if ($remote_addr = "1.2.3.4") {
set $cachevalidval "1m";
}
proxy_pass http://127.0.0.1:80;
proxy_cache gitweb;
proxy_cache_valid any $cachevalidval;

I get complaints that $cachevalidval is an invalid time value. I've
tried doing things like having $cachevalidval only have a number and
then using "$cachevalidval"m but nothing works so far...

Thanks,
Jeff

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Setting cache parameters via if directives

Jeff Mitchell January 28, 2011 12:10AM

Re: Setting cache parameters via if directives

Ryan Malayter January 28, 2011 11:00AM

Re: Setting cache parameters via if directives

Jeff Mitchell January 29, 2011 03:24AM

Re: Setting cache parameters via if directives

Jeff Mitchell January 29, 2011 11:10AM

Re: Setting cache parameters via if directives

agentzh February 01, 2011 03:50AM

Re: Setting cache parameters via if directives

agentzh February 01, 2011 03:56AM

Re: Setting cache parameters via if directives

Ryan Malayter February 01, 2011 10:50AM

Re: Setting cache parameters via if directives

valor January 29, 2011 07:02PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 179
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready