Updated output buffering to start earlier on the init hook instead of template_redirect. This was done to increase the compatibility with third parties (#78 and #120). Previously anything that added data to the HTML output before template_redirect was not being captured in our buffer. This means in some cases cached pages were incomplete and missing data. The output buffer does not start unless the template used is the directory index. (This is currently set to index.php but a filter will be added in case the directory index has been renamed and set in the server configuration file.) This will improve performance by not starting an output buffer when not needed. All other checks still need to be done in Cache_Enabler::_bypass_cache() because that data being checked is not available at init yet. If a page is expired the stale cached page will now be delivered (through PHP handling) while the cached page is being updated. Changing the output buffering timing in this way will allow PHP to automatically close the output buffer started by Cache Enabler instead of trying to clean our specific output buffer at a different hook fired later (because we would not be certain if the output buffer being cleaned is the one we started).
Updated regular expressions used for checking whether or not the trailing slash exists. This was updated to ensure file extensions that could potentially be cached (e.g. .xml) are also ignored (as briefly explained in 626aa59). This will make checking for trailing slashes more strict and prevent potential unwanted cache bypassing.
Added Cache_Enabler::_is_cacheable() to check whether or not the content of a page should even be cached. This will ensure invalid page content is not processed. This means Cache_Enabler::_is_sitemap() is no longer required and has been removed. Furthermore, checking if the output buffer is empty is not required when a page is only cacheable if it has the required HTML tags. This method was inspired by Autoptimize and is credited to @futtta (thank you).
Updated output buffering to start earlier on the
init
hook instead oftemplate_redirect
. This was done to increase the compatibility with third parties (#78 and #120). Previously anything that added data to the HTML output beforetemplate_redirect
was not being captured in our buffer. This means in some cases cached pages were incomplete and missing data. The output buffer does not start unless the template used is the directory index. (This is currently set toindex.php
but a filter will be added in case the directory index has been renamed and set in the server configuration file.) This will improve performance by not starting an output buffer when not needed. All other checks still need to be done inCache_Enabler::_bypass_cache()
because that data being checked is not available atinit
yet. If a page is expired the stale cached page will now be delivered (through PHP handling) while the cached page is being updated. Changing the output buffering timing in this way will allow PHP to automatically close the output buffer started by Cache Enabler instead of trying to clean our specific output buffer at a different hook fired later (because we would not be certain if the output buffer being cleaned is the one we started).Updated regular expressions used for checking whether or not the trailing slash exists. This was updated to ensure file extensions that could potentially be cached (e.g.
.xml
) are also ignored (as briefly explained in 626aa59). This will make checking for trailing slashes more strict and prevent potential unwanted cache bypassing.Added
Cache_Enabler::_is_cacheable()
to check whether or not the content of a page should even be cached. This will ensure invalid page content is not processed. This meansCache_Enabler::_is_sitemap()
is no longer required and has been removed. Furthermore, checking if the output buffer is empty is not required when a page is only cacheable if it has the required HTML tags. This method was inspired by Autoptimize and is credited to @futtta (thank you).Closes #78 and closes #120