Support » Plugin: WP Super Cache » [Plugin: WP Super Cache] nginx config
[Plugin: WP Super Cache] nginx config
-
Hello Donncha,
Your great plugin autogenerateв apache’s .htaccess config.
Could you spend a little time to write correct configuration for nginx?It is known that we can to find many 3rd party solutions by Google, but I want to get configuration from you to make sure that everything is correct!
I think many people would agree with me 🙂
Thanks.
-
I agree too, but I don’t use nginx and don’t have time to write the code that supports it. If anyone wants to submit a patch …
I’m sure there is sufficient number of specialists to offer comprehensive configuration.
Could you add webserver detection and generate appropriate configuration in new plugin version?What about this solution:
# WP Super Cache rules. # Enable detection of the .gz extension for statically compressed content. # Comment out this line if static gzip support is not compiled into nginx. gzip_static on; set $supercacheuri ""; set $supercachefile "$document_root/wp-content/cache/supercache/${http_host}${uri}index.html"; if (-e $supercachefile) { set $supercacheuri "/wp-content/cache/supercache/${http_host}${uri}index.html"; } # If this is a POST request, pass the request onto WordPress. if ($request_method = POST) { set $supercacheuri ""; } # If there is a query string, serve the uncached version. if ($query_string) { set $supercacheuri ""; } # Logged in users and those who have posted a comment get the non-cached version. if ($http_cookie ~* comment_author_|wordpress_logged_in|wp-postpass_) { set $supercacheuri ""; } # Mobile browsers get the non-cached version. # Wastes CPU cycles if there isn't a mobile browser WP theme for the site. if ($http_x_wap_profile) { set $supercacheuri ""; } if ($http_profile) { set $supercacheuri ""; } 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)) { set $supercacheuri ""; } 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-)) { set $supercacheuri ""; } # Stop processing if the supercache file is valid. if ($supercacheuri) { rewrite ^ $supercacheuri break; }
We have it enabled on more blogs, just ignore the mod_rewrite Warning, enable gzip_static.
#wenn file existiert gleich anzeigen if (-f $request_filename) { break; } set $supercache_file ''; set $supercache 1; set $supercache_uri $request_uri; set $ihttp_host ''; if ($request_method = POST) { set $supercache 0; } # Using pretty permalinks, so bypass the cache for any query string set $qs 0; if ($query_string) { set $qs 1; } #supercaching when coming from twitter, facebook, feedburner if ($query_string ~* "^utm_source=([^&]+)&utm_medium([^&]+)&utm_campaign=([^&]+)(&utm_content=([^&]+))?$") { set $qs 0; set $supercache_uri $document_uri; } #set $qs 1; #if querystring test not passed, not caching #deactivate on high load if ($qs = 1) { set $supercache 0; } #deactivate it on high traffic if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) { set $supercache 0; } #mobile device support #RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mob)$ #RewriteCond %{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|)$ #if ($http_user_agent ~* '^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mob)$') { # set $supercache 0; #} #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|)$') { # set $supercache 0; #} if ($http_user_agent ~* '(iphone|ipod|aspen|incognito|webmate|android|dream|cupcake|froyo|blackberry9500|blackberry9520|blackberry9530|blackberry9550|blackberry 9800|webos|s8000|bada)') { # set $ihttp_host '-mobile'; set $supercache 0; } # if we haven't bypassed the cache, specify our supercache file if ($supercache = 0 ) { set $supercache_uri ''; } if ($supercache_uri ~ ^(.+)$) { set $supercache_file /wp-content/cache/supercache/$http_host$1/index${ihttp_host}.html; } # only rewrite to the supercache file if it actually exists if (-f $document_root$supercache_file) { rewrite ^ $supercache_file last; # rewrite ^(.*)$ $supercache_file last; }
+ for thought:
nginx + php-fpm + PHP APC + WordPress multisite (subdirectory) + WP Super Cache
Nginx’s experts, I do not have good skill to create final version of most competent, comprehensive and actually config. Need some help.
Thanks.
- The topic ‘[Plugin: WP Super Cache] nginx config’ is closed to new replies.