Closed stevegrunwell closed 3 years ago
Thanks for all of the work you've been putting into this plugin, Steve. It's really been great to see. I've actually intentionally avoided adding this type of behavior but am open to discussing its implementation. For cache troubleshooting I have thought the plugin can either be deactivated, which I see wouldn't work if Cache Enabler is used as a must-use plugin, WP_CACHE
can be set to false
, or a query string can be appended to the page URL (depending on the query strings that are excluded). For example, by default something like https://www.example.com/path/to/page/?nocache
or https://www.example.com/path/to/page/?bypass_cache_enabler=1
could be used.
I see a few major benefits of having a setting over relying solely on the WP_CACHE
constant, most of which come down to better understanding the site owner's intent:
wp-config.php
files directly, as that's a common cause of issues for less-technical site owners.advanced-cache.php
file. Alternately, if they do have it enabled but the site cache isn't working, the alerts help guide them to the desired state.WP_CACHE
(since Apache would capture the request before it ever makes it down to PHP).As you alluded to above, we're dealing with a situation where Cache Enabler will be running as an MU plugin, so deactivation would no longer be an option in our case. This seems like a reasonable way to let site owners opt-out of the functionality (whether troubleshooting or longer-term), while preventing them from running out-of-date versions of the plugin.
Those points are great to know. I appreciate the detail as it allows me to understand the cases I'm unaware of.
Let me think about this change a little bit more and get back to this next week.
That was a long week. 😉 Over the last few version branches we've been setting up Cache Enabler to be more server oriented as the performance is far better. This has been in preparation for the request made by your colleague in #176 in addition to other features that we want to bring to Cache Enabler.
You've made really great points that I believe makes adding this type of behavior important. We plan on implementing this in some way in the future before or at the time of #176, but it will be done slightly differently than what you've proposed. I do like "Cache Status" as it fits well. It also allows other status information to potentially be included, like data from the new cache iterator.
In case it helps for your current use case I thought I'd let you know in Cache_Enabler::get_default_settings()
we consider the system settings to be defined by Cache Enabler and not the user. The only place this may cause an issue for you is when Cache_Enabler::update_backend()
is called. That would cause the enabled
system setting you've added to overwrite whatever was potentially defined in the database. I'm unsure if that matters in your case but I thought I'd let you know.
In situations where site owners might need to troubleshoot some caching issues but don't want to completely disable Cache Enabler, it's helpful to have the ability to pause the cache.
This PR adds a new "Cache Status" section to the top of the plugin settings screen, with a single option: "Enable the site cache". When checked (default behavior), it's assumed that the site owner wants the site cache enabled, and the plugin will proceed with checks around a missing
advanced-cache.php
file, theWP_CACHE
constant, etc. However, when the page cache is disabled, these warnings are suppressed and both the constant and drop-in are removed. Re-enabling the page cache will then re-runCache_Enabler_Disk::setup()
, which puts these items back into place.