keycdn / cache-enabler

A lightweight caching plugin for WordPress that makes your website faster by generating static HTML files.
https://wordpress.org/plugins/cache-enabler/
123 stars 46 forks source link

update WP_CACHE handling and fix cache handling #102

Closed coreykn closed 4 years ago

coreykn commented 4 years ago

Update Cache_Enabler::_set_wp_cache():

Fix Cache_Enabler_Disk::_file_path() issue that was introduced in version 1.4.0 when I changed the Cache_Enabler_Disk::_file_path() to use get_site_url() (PR #96). This caused the WordPress default domain redirect to not occur if the cached page already existed (e.g. https://example.com would not redirect to https://www.example.com after https://www.example.com was cached). This occurred because Cache_Enabler_Disk::_file_path() was able to find the cached page through get_site_url() and then deliver it (by PHP). Instead, get_site_url() should only be used when a $path parameter is provided, like when clearing the cache by URL.

Add cache bypass method for the WP_CACHE constant. By default WordPress core will define WP_CACHE as false (in the wp-includes/default-constants.php file), so checking defined( 'WP_CACHE' ) will always return true (meaning all ! defined( 'WP_CACHE' ) checks are unnecessary and have been removed). Cache will now be bypassed if define('WP_CACHE', false); is set, either by the WordPress core or in the wp-config.php file. This allows Cache Enabler to honor the WP_CACHE constant and is also helpful in the event caching needs to be disabled in certain environments (e.g. development).

Fix advanced cache settings issue that occurred in version 1.4.0 by adding a temporary clean in Cache_Enabler::on_ce_update() to delete incorrect file(s).

Add nonce names back that were removed in PR #96. Keep the names for now (instead of the default) but use better naming convention in the future.

Add translation descriptions for translators to improve the internationalization process and help expand the localization.