On my local test Wordpress install I installed Cache Enabler and updated to 1.4.6 but I see from https://github.com/keycdn/cache-enabler/pull/94 the cache filed is now scheme based. However, if I setup a non-https wordpress site i.e. http://cache-enabler.domain.com the Cache Enabler still generates a https-index.html instead of http-index.html file ?
ls -lah /home/nginx/domains/cache-enabler.domain.com/public/wp-content/cache/cache-enabler/cache-enabler.domain.com/
total 40K
drwxrws--- 2 nginx nginx 4.0K Aug 27 03:02 .
drwxrws--- 3 nginx nginx 4.0K Aug 27 03:02 ..
-rw-rw---- 1 nginx nginx 24K Aug 27 03:02 https-index.html
-rw-rw---- 1 nginx nginx 6.6K Aug 27 03:02 https-index.html.gz
+--------------------+----------+--------+---------+
| name | status | update | version |
+--------------------+----------+--------+---------+
| akismet | inactive | none | 4.1.6 |
| autoptimize | active | none | 2.7.7 |
| autoptimize-gzip | active | none | 0.1 |
| cache-enabler | active | none | 1.4.6 |
| cdn-enabler | inactive | none | 1.0.9 |
| classic-editor | active | none | 1.6 |
| disable-xml-rpc | active | none | 1.0.1 |
| pretty-search-url | active | none | 0.1 |
| sucuri-scanner | active | none | 1.8.24 |
| webp-express | active | none | 0.17.5 |
| advanced-cache.php | dropin | none | |
+--------------------+----------+--------+---------+
I setup my Nginx advanced cache rules to use $scheme nginx variable to prefix index.html with either https- or http- but this wouldn't work if Cache Enabler is generating https- prefix even for non-https setup Wordpress site !
# default html file
set $cache_enabler_uri '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri}${scheme}-index.html';
# webp html file
if ($http_accept ~* "image/webp") {
set $cache_enabler_uri '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri}${scheme}-index-webp.html';
}
PHP 7.3.21
php -v
PHP 7.3.21 (cli) (built: Aug 12 2020 22:45:53) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.21, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.21, Copyright (c) 1999-2018, by Zend Technologies
Maybe instead of using port 443/80 to determine if https or https prefix is set, use $_SERVER['REQUEST_SCHEME'] and/or $_SERVER['HTTPS'] ? This would also allow non-standard ports to map correctly i.e. HTTP site on port 8080 or HTTPS site on port 8443 would be properly detected too. edit: looks like you did that in https://github.com/keycdn/cache-enabler/commit/beac15dbe6806330fd8478c911564d7e6045c004
however, my phpinfo reports $_SERVER['HTTPS'] | off so for non-https site the variable isn't empty but = off so maybe that falsely matches your check ?
ls -lah /home/nginx/domains/cache-enabler.domain.com/public/wp-content/cache/cache-enabler/cache-enabler.domain.com/
total 40K
drwxrws--- 2 nginx nginx 4.0K Aug 27 04:41 .
drwxrws--- 3 nginx nginx 4.0K Aug 27 04:41 ..
-rw-rw---- 1 nginx nginx 24K Aug 27 04:41 http-index.html
-rw-rw---- 1 nginx nginx 6.6K Aug 27 04:41 http-index.html.gz
I checked on Apache PHP server $_SERVER['HTTPS'] is empty none existent on non-https requests but on Nginx with PHP-FPM $_SERVER['HTTPS'] is set to off for non-https requests
On Nginx/PHP-FPM https request shows $_SERVER['HTTPS'] | on
the browser request that generated the cached file
On my local test Wordpress install I installed Cache Enabler and updated to 1.4.6 but I see from https://github.com/keycdn/cache-enabler/pull/94 the cache filed is now scheme based. However, if I setup a non-https wordpress site i.e.
http://cache-enabler.domain.com
the Cache Enabler still generates ahttps-index.html
instead ofhttp-index.html
file ?from wp-cli
I setup my Nginx advanced cache rules to use $scheme nginx variable to prefix index.html with either
https-
orhttp-
but this wouldn't work if Cache Enabler is generatinghttps-
prefix even for non-https setup Wordpress site !PHP 7.3.21
phpinfo variables report
Maybe instead of using port 443/80 to determine if https or https prefix is set, use
$_SERVER['REQUEST_SCHEME']
and/or$_SERVER['HTTPS']
? This would also allow non-standard ports to map correctly i.e. HTTP site on port 8080 or HTTPS site on port 8443 would be properly detected too. edit: looks like you did that in https://github.com/keycdn/cache-enabler/commit/beac15dbe6806330fd8478c911564d7e6045c004and verified my copy has that
however, my phpinfo reports
$_SERVER['HTTPS'] | off
so for non-https site the variable isn't empty but = off so maybe that falsely matches your check ?so maybe
which seems to work
I checked on Apache PHP server
$_SERVER['HTTPS']
is empty none existent on non-https requests but on Nginx with PHP-FPM$_SERVER['HTTPS']
is set to off for non-https requestsOn Nginx/PHP-FPM https request shows
$_SERVER['HTTPS'] | on
the browser request that generated the cached file