[Plugin: WP Super Cache] Nginx and WordPress Super Cache (WordPress MU)
-
I’m working on moving my bogged down server (over 1000 students, each with their own site in a multisite setup) to a new server running nginx for better performance along with php-fpm.
I’ve gotten nginx and wordpress working, but I can’t seem to get Super Cache working, the timestamps on the pages never match.
I have been following: https://codex.www.ads-software.com/Nginx
My sites enabled file:
# Redirect everything to the main site. server { listen 80 default; server_name *.students.scisdragons.net; rewrite ^ https://students.scisdragons.net$request_uri permanent; } server { listen 80; server_name students.scisdragons.net; root /var/www/students.scisdragons.net; include global/restrictions.conf; include global/wordpress-ms-subdir.conf; }
My WordPress MU file:
# WordPress multisite subdirectory rules. # Designed to be included in any server {} block. # This order might seem weird - this is attempted to match last if rules below fail. # https://wiki.nginx.org/HttpCoreModule location / { try_files $uri $uri/ /index.php?$args; } # Add trailing slash to */wp-admin requests. rewrite /wp-admin$ $scheme://$host$uri/ permanent; # Directives to send expires headers and turn off 404 error logging. location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires 48h; log_not_found off; } # Pass uploaded files to wp-includes/ms-files.php. rewrite /files/$ /index.php last; # For multisite: Use a caching plugin/script that creates symlinks to the correct subdirectory structure to get some performance gains. set $cachetest "$document_root/wp-content/cache/ms-filemap/${host}${uri}"; if ($uri ~ /$) { set $cachetest ""; } if (-f $cachetest) { # Rewrites the URI and stops rewrite processing so it doesn't start over and attempt to pass it to the next rule. rewrite ^ /wp-content/cache/ms-filemap/${host}${uri} break; } if ($uri !~ wp-content/plugins) { rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last; } # Uncomment one of the lines below for the appropriate caching plugin (if used). # include global/wordpress-ms-subdir-wp-super-cache.conf; # include global/wordpress-ms-subdir-w3-total-cache.conf; # Rewrite multisite '.../wp-.*' and '.../*.php'. if (!-e $request_filename) { rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last; rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last; } # Pass all .php files onto a php-fpm/php-fcgi server. location ~ \.php$ { # Zero-day exploit defense. # https://forum.nginx.org/read.php?2,88845,page=3 # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi. # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked. try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # fastcgi_intercept_errors on; fastcgi_pass php; }
When I include the following super cache file and restart nginx it doesn’t seem to make a difference:
# WP Super Cache rules. # Designed to be included from a 'wordpress-ms-...' configuration file. # 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|Nok$ 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$ set $supercacheuri ""; } # Stop processing if the supercache file is valid. if ($supercacheuri) { rewrite ^ $supercacheuri break; }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘[Plugin: WP Super Cache] Nginx and WordPress Super Cache (WordPress MU)’ is closed to new replies.