location / {
# Enables the Gzip Static Module (this must be added via --with-http_gzip_static_module
# Compile option when you compile Nginx in order to use Gzip Precompression
# If you don't have it installed you'll only be able to serve the uncompressed html files
gzip_static on;
# Disables serving of Gzipped content to IE6 and earlier
gzip_disable "MSIE [1-6]\.";
# Sets the default mime type to text/html
default_type text/html;
if (-f $request_filename) {
break;
}
# Prepares some variables to aid us in determining the existance of the cache
set $supercache_file '';
set $supercache_uri $request_uri;
# Do not use the cache when submitting something such as a comment (ie: goto PHP)
if ($request_method = POST) {
set $supercache_uri '';
}
# Do not use the cache when submitting a query (ie: goto PHP for parsing)
if ($query_string) {
set $supercache_uri '';
}
# Do not use the cache where it may cause problems
if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
set $supercache_uri '';
}
# If the variable has not been emptied assign the usual cached file location
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
}
# If the cached file exists, rewrite the browsers request to the cached file location
if (-f $document_root$supercache_file) {
rewrite ^(.*)$ $supercache_file break;
}
# If the cached file location does not exit, or is blank, and the file requested does not exist
# Fall back to index.php to be parsed dynamically
if (!-e $request_filename) {
rewrite . /index.php last;
}
}