Skip to content

Instantly share code, notes, and snippets.

@mertcangokgoz
Last active April 28, 2019 23:04
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 mertcangokgoz/ae82c443a457405f835144dd1e79dfa2 to your computer and use it in GitHub Desktop.
Save mertcangokgoz/ae82c443a457405f835144dd1e79dfa2 to your computer and use it in GitHub Desktop.
location / {
error_page 418 = @cachemiss;
error_page 419 = @mobileaccess;
recursive_error_pages on;
if ($request_method = POST) { return 418; }
if ($arg_s != "") { return 418; }
if ($arg_p != "") { return 418; }
if ($arg_amp != "") { return 418; }
if ($arg_preview = "true") { return 418; }
if ($arg_ao_noptimize != "") { return 418; }
if ($http_cookie ~* "wordpress_logged_in_") { return 418; }
if ($http_cookie ~* "comment_author_") { return 418; }
if ($http_cookie ~* "wp_postpass_") { return 418; }
if ( $http_user_agent = "Amazon CloudFront" ) { return 403; }
if ( $http_user_agent ~* "2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800|iPad" ) { return 419; }
add_header "Vary" "User-Agent";
if ( $http_user_agent ~* "w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-|ipad" ) { return 419; }
try_files "/wp-content/cache/all/${uri}index.html" $uri $uri/ /index.php$is_args$args;
add_header "X-Cache" "HIT - WP Fastest Cache";
add_header "X-CF-Powered-By" "WP Fastest Cache";
add_header "Vary" "Cookie";
expires 30m;
add_header "Cache-Control" "must-revalidate";
}
location @mobileaccess {
try_files "/wp-content/cache/wpfc-mobile-cache/${uri}index.html" $uri $uri/ /index.php$is_args$args;
add_header "X-Cache" "HIT - Mobile - WP Fastest Cache";
add_header "Vary" "User-Agent, Cookie";
expires 30m;
add_header "Cache-Control" "must-revalidate";
}
location @cachemiss {
try_files $uri $uri/ /index.php$is_args$args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment