Skip to content

Instantly share code, notes, and snippets.

@sebastianmoran-mainwp
Created June 4, 2019 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastianmoran-mainwp/425b72b8ea1b728066bd9caf26dc331d to your computer and use it in GitHub Desktop.
Save sebastianmoran-mainwp/425b72b8ea1b728066bd9caf26dc331d to your computer and use it in GitHub Desktop.
WP Performance - NGNIX Config Example
# 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