Welcome! Log In Create A New Profile

Advanced

Setting cache parameters via if directives

Jeff Mitchell
January 28, 2011 12:10AM
Hello,

We have a particular application (gitweb) that performs a particular,
extraordinarily slow function when the home page is loaded. As the
number of repositories has increased, this has grown to take several
*minutes* per page view (yes, ugh).

To combat this, we tried setting up cache so that this only occurs once
an hour, but it's still causing too much of a problem...both because it
doesn't always last an hour (sometimes we see the delay happen again
sooner) and because when it does expire, it simply takes too long (and
if multiple clients connect at that same time making that request, it
gets even worse).

As a result, what I'd like to do is to have the cache expire after an
hour, but once every twenty or thirty minutes manually refresh the
cache. That way clients can use the existing cache while the new page is
being rebuilt, which will then save the new values into the cache and
reset the timer.

So my thought was that I could do something like the code below, but it
doesn't work since I can't put the directives I want into the if block,
and the proxy_pass in the if block (if I remove the cache values) honors
the cache values in the outside location block anyways:

location = / {
if ($remote_addr = "1.2.3.4") {
proxy_pass http://127.0.0.1:80;
proxy_cache gitweb;
proxy_cache_valid 200 20m;
proxy_read_timeout 300;
proxy_send_timeout 300;
}
proxy_pass http://127.0.0.1:80;
proxy_cache gitweb;
proxy_cache_valid 200 60m;
proxy_cache_use_stale off;
proxy_read_timeout 60;
proxy_send_timeout 60;
}

Any help much appreciated.

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: 119
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready