Jun 27, 2014

Nginx proxy cache setting for Moin

MoinMoin is a nice wiki. I tried to cache it, and luckily succeed:

# Save this, e.g.: /etc/nginx/proxy_cache for reusable
proxy_cache zone-cache;

# Should add more if
proxy_cache_key "$host$request_uri";
proxy_cache_valid any 1d;
proxy_cache_methods GET HEAD;
proxy_ignore_headers Set-Cookie Cache-Control Expires;
proxy_hide_header Cache-Control;
proxy_hide_header Expires;
proxy_http_version 1.1;

server {
     proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=zone-cache:4m max_size=1000m;    
     location @moin {
        include proxy_cache;
        proxy_pass http://127.0.0.1:8080;
        # each application need specify when to by pass cache
        set $no_cache 0;
        if ($query_string ~* "action=") {
            set $no_cache 1;
        }
        if ($http_cookie ~* "MOIN_SESSION_") {
            set $no_cache 1;
        }
        proxy_cache_bypass $no_cache;
    }
    location / {
        try_files $uri @moin;
    }
    location /moin_static197/ {
        alias /srv/moin/web/static/htdocs/;
    }
    # more here
}

No comments:

Post a Comment

New comment