diff --git a/lib/general b/lib/general index 49ef83a..f5c2760 100644 --- a/lib/general +++ b/lib/general @@ -1310,12 +1310,36 @@ check_var() { # client_max_body_size,upload_max_filesize,post_max_size elif [[ $1 == "max-mb-uploads" ]]; then - [[ -n $(conf_read max-mb-uploads) && $(conf_read max-mb-uploads) =~ ^[0-9]+$ && $(conf_read max-mb-uploads) -gt 0 ]] && local out=$(conf_read max-mb-uploads) || local out=100 + [[ -n $(conf_read max-mb-uploads) && $(conf_read max-mb-uploads) =~ ^[0-9]+$ && $(conf_read max-mb-uploads) -gt 0 ]] && local out=$(conf_read max-mb-uploads) || local out=100 # FastCGI Cache size elif [[ $1 == "run-folder-size" ]]; then [[ -n $(conf_read run-folder-size) && $(conf_read run-folder-size) =~ ^[0-9]+$ && $(conf_read run-folder-size) -gt 10 && $(conf_read run-folder-size) -le "70" ]] && local out=$(conf_read run-folder-size) || local out=25 + # FastCGI Cache: Query Strings + elif [[ $1 == "wpcache-query-strings" ]]; then + if [[ $(conf_read wpcache-query-strings) =~ ^(all|never)$ ]]; then + local out=$(conf_read wpcache-query-strings) + else + local out="false" + fi + + # FastCGI Cache: Exclude URL + elif [[ $1 == "wpcache-exclude-url" ]]; then + if [[ -z $(conf_read wpcache-exclude-url) ]]; then + local out="/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|.*sitemap.*\.xml|/feed/|/account/|/add_to_cart/|/cart/|/my-account/|/checkout/|/logout/" + else + local out=$(conf_read wpcache-exclude-url) + fi + + # FastCGI Cache: Exclude Cookie + elif [[ $1 == "wpcache-exclude-cookie" ]]; then + if [[ -z $(conf_read wpcache-exclude-cookie) ]]; then + local out="comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|[a-z0-9]+_items_in_cart|[a-z0-9]+_cart_hash" + else + local out=$(conf_read wpcache-exclude-cookie) + fi + # Nginx Error Log Level elif [[ $1 == "nginx-error-log-level" ]]; then [[ -n $(conf_read nginx-error-log-level) && $(conf_read nginx-error-log-level) =~ ^(info|notice|warn|error|crit|alert|emerg)$ ]] && local out=$(conf_read nginx-error-log-level) || local out="false" diff --git a/lib/install b/lib/install index ca6ec28..5b0ec56 100644 --- a/lib/install +++ b/lib/install @@ -282,6 +282,11 @@ nginx_optim() { sudo sed -i "/worker_rlimit_nofile /c \worker_rlimit_nofile $fd_per_process;" /etc/nginx/nginx.conf sudo sed -i "/open_file_cache max /c \ open_file_cache max=$(($fd_per_process/3)) inactive=5m;" /etc/nginx/nginx.conf + # WP Cache + [[ $(check_var wpcache-query-strings) == "all" ]] && sudo sed -i '/# URL with a query string should always go to php/,/\} #End/{/.*/d}' /etc/nginx/common/wpfc.conf + sudo sed -i "s##$(check_var wpcache-exclude-url)#" /etc/nginx/common/wpfc.conf + sudo sed -i "s##$(check_var wpcache-exclude-cookie)#" /etc/nginx/common/wpfc.conf + # Remove it, then add it again to prevent multiple # for each server-reset sudo sed -i '/ SERVER_NAME /s/#//' /etc/nginx/fastcgi_params sudo sed -i '/ SERVER_NAME /s/^/#/' /etc/nginx/fastcgi_params diff --git a/templates/general/conf b/templates/general/conf index 1852b3f..bf340aa 100644 --- a/templates/general/conf +++ b/templates/general/conf @@ -96,15 +96,6 @@ #sftp-www-data:false -# FastCGI Cache -# Values: