Skip to content

Commit

Permalink
Added mobile conf for common server include
Browse files Browse the repository at this point in the history
  • Loading branch information
gagan0123 committed Sep 18, 2019
1 parent b7cf714 commit 2eed50f
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions configs/nginx-common/wpfc-mobile.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# WPFC NGINX CONFIGURATION

set $skip_cache 0;
set $var_desktop "fullversion";
set $var_mobile "mobileversion";
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
set $skip_cache 1;
}

# Uncomment to bypass URLs with Query Strings
#if ($query_string != "") {
# set $skip_cache 1;
#}

# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)|/flow/.*.php.*") {
set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenter or customer with items in cart
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_items_in_cart") {
set $skip_cache 1;
}
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ {
try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi.conf;
fastcgi_pass $fpmpool;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS;
fastcgi_cache_use_stale error timeout invalid_header updating http_500;
fastcgi_cache_valid 200 301 302 5m;
fastcgi_cache_valid 404 10m;
add_header X-Cache-Status $upstream_cache_status;
}
location ~ /purge(/.*) {
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1$var_desktop";
#fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1$var_mobile";
access_log off;
}
location ~ /mpurge(/.*) {
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1$var_mobile";
access_log off;
}

0 comments on commit 2eed50f

Please sign in to comment.