Bug while using "proxy_cache_use_stale updating"

saltyflorida nginx-forum at nginx.us
Wed Dec 16 07:09:09 MSK 2009


I was wondering if anyone else is still having this problem of Nginx getting stuck in the UPDATING state after upgrading to the fixed version of Nginx.

I saw this using Nginx 0.7.62 and I upgraded to 0.8.24 because I saw it had been fixed, but recently saw the problem again.

Here is my configuration:

    proxy_cache_path /mnt/nginx_cache levels=1:2
                     keys_zone=one:10m
                     inactive=7d max_size=10g;
    proxy_cache_path /mnt/nginx_cache_media levels=1:2
                     keys_zone=MEDIA:10m
                     inactive=7d max_size=5g;
    proxy_temp_path /var/www/nginx_temp;

    server {
        listen 80;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_pass_header Set-Cookie;
        client_max_body_size 8m;

        # capture cookies for use in the cache key
        set $wordpress_logged_in "";
        set $comment_author_email "";
        set $comment_author "";
        if ($http_cookie ~* "wordpress_logged_in_[^=]*=([^%]+)%7C") {
            set $wordpress_logged_in wordpress_logged_in_$1;
        }
        if ($http_cookie ~* "comment_author_email_[^=]*=([^;]+)(;|$)") {
            set $comment_author_email comment_author_email_$1;
        }
        if ($http_cookie ~* "comment_author_[^=]*=([^;]+)(;|$)") {
            set $comment_author comment_author_$1;
        }
        set $my_cache_key $scheme$host$uri$is_args$args$wordpress_logged_in$comment_author_email$comment_author;

        # proxy cache config for media files
        location ~* \.(gif|jpg|jpeg|png|js|css)$ {
            proxy_pass http://backend;
            proxy_cache MEDIA;
            proxy_cache_key $my_cache_key;

            proxy_cache_valid  200 302 304 30d;
            proxy_cache_valid  301 1h;
            proxy_cache_valid  any 1m;
            proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504 http_404;
            expires 30d;
        }

        # proxy cache config for all other files
        location / {
            proxy_pass http://backend;
            proxy_cache one;
            proxy_cache_key $my_cache_key;

            proxy_cache_valid  200 302 304 10m;
            proxy_cache_valid  301 1h;
            proxy_cache_valid  any 1m;
            proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504 http_404;
        }

        # Don't use the cache for the following locations
        location /wp-admin {
            proxy_read_timeout 180;
            proxy_pass http://backend;
        }
        location /wp-login.php { proxy_pass http://backend; }
    }


Posted at Nginx Forum: http://forum.nginx.org/read.php?2,5225,30772#msg-30772




More information about the nginx mailing list