Exclude specific location from cache

Dewangga Bachrul Alam dewanggaba at xtremenitro.org
Thu Dec 24 09:01:54 UTC 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hello!

Currently my configuration looks like this :

map $request_method $purge_method {
    PURGE 1;
    default 0;
}

map $arg_geoloc $bypass {
        default 1;
        1       0;
}

# Exclude from cache
# Expected URL http://domain.tld/
location = / {
        proxy_pass [..];
        proxy_no_cache $bypass;
        proxy_cache_bypass $bypass;
}

# Expected URL http://domain.tld/indeks/*
# Expected URL http://domain.tld/kanal/*
location ~ ^/(indeks|kanal)/ {
        proxy_pass [..];
        proxy_no_cache $bypass;
        proxy_cache_bypass $bypass;
}

# The rest are cached
# Expected URL http://domain.tld/* (except the condition above)
location / {
        proxy_pass [..];
        proxy_cache     my_cache;
        proxy_cache_purge       $purge_method;
        proxy_cache_use_stale error timeout updating http_500 http_502
http_503 http_504;
        proxy_cache_valid 200 206 302 1h;
        proxy_cache_valid any 3s;
        proxy_cache_lock on;
        proxy_cache_revalidate on;
        proxy_cache_min_uses 10;
}

My goal is, exclude the homepage, indeks and kanal pages, then cache
the rest URL. Am I right with the configuration above?

Any help and advice are appreciated.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJWe7R/AAoJEOV/0iCgKM1w+o4P/RuZ3NJ1BiQ1B30kapHsAHhm
ylW7O8E0Qx5vLF8aR0BzI3TTTsHEva9jXOrHwOf1+CiT+z/07IBvhjqDHOKhKdr5
46kMM9m/7L5ZEmH+AWM/InDQWgVkvP1UEJkYNoOAGB/NkT+zVv7g+MvJEmcf/abP
BJxektr8j8NldhNx5QiSZswz2AChpg67wh/aWX0Q4vtytZOYn+1/lxMteQjrRBQa
Ub75uw5yiPIKLTABdEBUJV4ulI+yel8VD6o0LOc1xbt4MUh/31Vp8kN5YziOhOK8
DB5bvCdLTFHyu8Bv8sAEmhuPxJiJ9Y9oL/HHVp5NTkDqNle7Otnr/f25jxnSFcYK
9OLY5UbWw6We8nJMk1psKbVWXPMdUBnAIvdRfIMcgHHb7QFmxxBfoCLiN7Xpt60g
v4o7pGa5Oz/OVE/XdUT79uLE9vbRdFM8ZoXxkLa2mTPvUzndXuqyzgx+2GAlghb8
5te+y/aCskYAL9b/retRQrp/dBBe3TqY9Ni8CTuoZ+SgUOhk07aYIGB7Q7pEY5Sd
cauWrxT4ijthE/GOM3NP7lVEtq5Cz+XDb9n5V2PFqxYi1LsLix6sYCIYwnYkVAqV
E44MAuViVFpj+NULcriNnU3HNJB6OWQdoEcNXodHUwm71k8ctPUSBrQK5w6c42xP
R6qDdDpqFU0oKoooXRHG
=tzpt
-----END PGP SIGNATURE-----



More information about the nginx mailing list