Created
June 4, 2019 04:00
-
-
Save sebastianmoran-mainwp/425b72b8ea1b728066bd9caf26dc331d to your computer and use it in GitHub Desktop.
WP Performance - NGNIX Config Example
This file contains 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
# WPP Expire start | |
location ~* \.(css|js|ico|gif|jpeg|jpg|webp|png|svg|eot|otf|woff|woff2|ttf|ogg|pdf)$ { | |
expires 30d; | |
} | |
# WPP Expire end | |
# WPP GZIP start | |
gzip on; | |
gzip_vary on; | |
gzip_proxied any; | |
gzip_comp_level 6; | |
gzip_buffers 16 8k; | |
gzip_http_version 1.1; | |
gzip_types image/svg+xml text/plain text/html text/xml text/css text/javascript application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript application/x-font-ttf application/vnd.ms-fontobject font/opentype font/ttf font/eot font/otf; | |
# WPP GZIP end | |
# WPP Cache load start | |
set $wpp_cache 1; | |
set $wpp_mobile 1; | |
set $wpp_amp 1; | |
if ($request_method = POST){ | |
set $wpp_cache 0; | |
} | |
if ($is_args) { | |
set $wpp_cache 0; | |
} | |
if (-f "$document_root/.maintenance") { | |
set $wpp_cache 0; | |
} | |
if ($http_cookie ~* (wordpress_logged_in_|wp\-postpass_|wptouch_switch_toggle|comment_author_|comment_author_email_)) { | |
set $wpp_cache 0; | |
} | |
if (!-f "/home/s762/html/wp-content/cache/wpp-cache/$http_host/$request_uri/index.html") { | |
set $wpp_cache 0; | |
} | |
if (!-f "/home/s762/html/wp-content/cache/wpp-cache/$http_host/$request_uri/index.html_mobile") { | |
set $wpp_mobile 0; | |
} | |
if ($http_user_agent ~* (Mobile|Android|Kindle|BlackBerry|Opera+Mini|Opera+Mobi)) { | |
set $wpp_cache "{$wpp_cache}{$wpp_mobile}"; | |
} | |
if ($request_uri ~* /amp/$) { | |
set $wpp_cache "{$wpp_cache}{$wpp_mobile}{$wpp_amp}"; | |
} | |
if ($wpp_cache = 111){ | |
rewrite .* /wp-content/cache/wpp-cache/$http_host/$request_uri/index.html_mobile_amp last; | |
} | |
if ($wpp_cache = 101){ | |
rewrite .* /wp-content/cache/wpp-cache/$http_host/$request_uri/index.html_amp last; | |
} | |
if ($wpp_cache = 11){ | |
rewrite .* /wp-content/cache/wpp-cache/$http_host/$request_uri/index.html_mobile last; | |
} | |
if ($wpp_cache = 1){ | |
rewrite .* /wp-content/cache/wpp-cache/$http_host/$request_uri/index.html last; | |
} | |
# WPP Cache load end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment