danangds

wp-fastest-cache.conf wp fastest cache plugin Ngin

Jul 20th, 2020
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.00 KB | None | 0 0
  1. location / {
  2.     error_page 418 = @cachemiss; # to handle cache misses
  3.     #error_page 419 = @mobileaccess; # to handle mobile visits
  4.     recursive_error_pages on;
  5.  
  6.     # bypass POST requests
  7.     if ($request_method = POST) { return 418; }
  8.  
  9.     # uncommenting the following degrades the performance on certain sites. YMMV
  10.     # if ($query_string != "") { return 418; }
  11.  
  12.     # bypass cache for common query strings
  13.     if ($arg_s != "") { return 418; } # search query
  14.     if ($arg_p != "") { return 418; } # request a post / page by ID
  15.     if ($arg_amp != "") { return 418; } # amp test
  16.     if ($arg_preview = "true") { return 418; } # preview post / page
  17.     #if ($arg_ao_noptimize != "") { return 418; } # support for Autoptimize plugin
  18.  
  19.     # if WP related cookies are found, skip cache
  20.     if ($http_cookie ~* "wordpress_logged_in_") { return 418; }
  21.     if ($http_cookie ~* "comment_author_") { return 418; }
  22.     if ($http_cookie ~* "wp_postpass_") { return 418; }
  23.  
  24.     # avoid duplicate content on Amazon CloudFront and KeyCDN.
  25.     #if ( $http_user_agent = "Amazon CloudFront" ) { return 403; access_log off; }
  26.     #if ($http_x_pull = "KeyCDN") { return 403; access_log off; }
  27.  
  28.     # uncomment the following, if WP Fastest Cache plugin is set to create a separate cache for mobile visitors
  29.     # 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; }
  30.     # add_header "Vary" "User-Agent";
  31.  
  32.     # uncomment the following if deemed fit, in addition to the above line to enable @mobileaccess
  33.     # 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; }
  34.  
  35.     # look for cached version; if-not-found, then send the request to PHP
  36.     try_files "/wp-content/cache/all/${uri}index.html" $uri $uri/ /index.php?$args;
  37.    
  38.     #Header untuk lokasi / yang dicache
  39.     include /etc/nginx/snippets/header-security.conf;
  40.     add_header Strict-Transport-Security "max-age=31536000";
  41.  
  42.     #--> all the following would apply, only if the request hits the cache
  43.  
  44.     #add_header "Vary" "Cookie";
  45. }
  46. location @cachemiss {
  47.     # on cache miss, send the request to PHP
  48.     try_files $uri $uri/ /index.php?$args;
  49. }
Add Comment
Please, Sign In to add comment