WP cache default settings now included in Webinoly configuration file.
This commit is contained in:
Cristhian Martínez Ochoa 2022-10-20 17:01:48 -06:00
parent 45b8d75e8e
commit 653f19e55b
5 changed files with 59 additions and 13 deletions

View file

@ -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"

View file

@ -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#<wpcache-exclude-url>#$(check_var wpcache-exclude-url)#" /etc/nginx/common/wpfc.conf
sudo sed -i "s#<wpcache-exclude-cookie>#$(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

View file

@ -96,15 +96,6 @@
#sftp-www-data:false
# FastCGI Cache
# Values: <time> (s,m,h,d,w,M,y)
# Default: 30d,7d,1m (Success,Inactive,Redirects)
# Note: https://webinoly.com/documentation/webinolys/#cache
# Same as: sudo webinoly -cache-valid
###########################
#fastcgi-conf:30d,7d,1m
# Nginx Access Logs Disabled
# Values: boolean (true/false)
# Default: true
@ -183,6 +174,28 @@
#awsiamrole:false
# FastCGI Cache
# Values: <time> (s,m,h,d,w,M,y)
# Default: 30d,7d,1m (Success,Inactive,Redirects)
# Note: https://webinoly.com/documentation/webinolys/#cache
# Same as: sudo webinoly -cache-valid
###########################
#fastcgi-conf:30d,7d,1m
# WordPress FastCGI Cache Defaults
# Values: all | never (query strings)
# Values: <uri>|<uri>... (url)
# Values: <cookie>|<cookie>... (cookie)
# Note: To revert any changes and set the original Webinoly defaults, just #comment these three variables and then server-reset.
# Note: Also, you can add further rules via command line using the proper commands described in the docs.
# Note: https://webinoly.com/documentation/webinolys/#cache
###########################
#wpcache-query-strings:never
#wpcache-exclude-url:/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|.*sitemap.*\.xml|/feed/|/account/|/add_to_cart/|/cart/|/my-account/|/checkout/|/logout/
#wpcache-exclude-cookie: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
# WordPress Login Basic Authentication
# Values: boolean (true/false)
# Default: true

View file

@ -12,15 +12,15 @@ set $skip_cache 0;
# URL with a query string should always go to php
if ($query_string != "") {
set $skip_cache 1;
}
} #End
# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|.*sitemap.*\.xml|/feed/|/account/|/add_to_cart/|/cart/|/my-account/|/checkout/|/logout/)") {
if ($request_uri ~* "(<wpcache-exclude-url>)") {
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|[a-z0-9]+_items_in_cart|[a-z0-9]+_cart_hash") {
if ($http_cookie ~* "<wpcache-exclude-cookie>") {
set $skip_cache 1;
}

View file

@ -263,6 +263,10 @@ elif [[ -n $custom_headers ]]; then
elif [[ -n $query_string_cache || -n $query_string_never_cache || -n $skip_cache || -n $skip_cookie_cache ]]; then
check_for_nginx
custom_cache_global
elif [[ -n $query_string_cache_default ]]; then
echo "${red}[ERROR] This option (-query-string-cache-default) is only enabled for specific sites using Custom Cache!"
echo "${blu}${dim}The option you are looking for is only available in the Webinoly configuration file. (wpcache-query-strings)${end}"
exit 1
elif [[ -n $email ]]; then