Skip to content

Instantly share code, notes, and snippets.

@trepmal
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trepmal/5bdf31321d19aa515534 to your computer and use it in GitHub Desktop.
Save trepmal/5bdf31321d19aa515534 to your computer and use it in GitHub Desktop.
# this goes in the http{} block
# remove any $no_cache "sets" from individual site confs (e.g. ` set $no_cache 0;`)
# 0 means we cache
# any other value will negate it
#check cookie for certain logged-in-type values, if found set 1
map $http_cookie $no_cookie_cache {
default 0;
"~comment_author_|wordpress_(?!test_cookie)|wp-postpass_" 1;
}
#check uri for certain logged-in-type values, if found set 1
#originally used $request_uri, but this includes the query string which makes it easier to bypass accidentally or maliciously
map $uri $no_uri_cache {
default 0;
"~wp-admin|wp-login.php" 2;
}
#finally, check if both values are 0 ("00"), any other combo means something should bypass
map $no_cookie_cache$no_uri_cache $no_cache {
default 1;
"00" 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment