Created
December 1, 2015 12:16
-
-
Save guiajlopes/12093348494ce7df5e8d to your computer and use it in GitHub Desktop.
supercache configration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- mode: nginx; mode:autopair; mode: flyspell-prog; ispell-local-dictionary: "american" -*- | |
| ### WP configuration for using the supercache plugin. | |
| ## Mimicking the .htaccess mod_rewrite rules in Nginx. They all return | |
| ## 405 which means unsupported method. | |
| ## The line below is no longer needed for supercache | |
| ## 0.9.9.9. Uncomment the 3 lines below if using and older version. | |
| # if ($request_uri ~ ^.*//.*$) { | |
| # return 405; | |
| # } | |
| ## POST means that it's not a cacheable request. | |
| if ($request_method = POST) { | |
| return 405; | |
| } | |
| ## Query string conditions. | |
| if ($query_string ~ ^.*=.*$) { | |
| return 405; | |
| } | |
| if ($query_string ~ ^.*attachment_id=.*$) { | |
| return 405; | |
| } | |
| ## If there's a cookie then bust the cache. | |
| if ($http_cookie ~ (?:comment_author_|wordpress_logged_in|wp-postpass_)) { | |
| return 405; | |
| } | |
| ## User agent wrangling for mobile access. | |
| if ($http_x_wap_profile ~ ^[a-z0-9\"]+) { | |
| return 405; | |
| } | |
| if ($http_profile ~ ^[a-z0-9\"]+) { | |
| return 405; | |
| } | |
| ## Mobile user agents should bypass the cache. | |
| 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).*) { | |
| return 405; | |
| } | |
| ## Mobile user agents should bypass the cache. | |
| 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-).*) { | |
| return 405; | |
| } | |
| ## Redefine 405 as named location nocache for further processing. | |
| error_page 405 = @nocache; | |
| ## Try the static files generated by WP supercache before relaying the | |
| ## request to PHP. | |
| try_files /wp-content/cache/supercache/${host}${uri}index.html $uri $uri/ /index.php?q=$uri&$args; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment