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

fix clear cache request handling #212

Closed coreykn closed 3 years ago

coreykn commented 3 years ago

Fix clear cache request handling to redirect to the current URL path with the query parameters _cache, _action, _wpnonce removed instead of wp_get_referer(). Previously, if the Referer request header was not sent, like if Referrer-Policy: no-referrer response header was set, this would cause the redirect to be cancelled and then script to be terminated. This lead to the response body being empty.

The clear URL can have query strings so $_SERVER['REQUEST_URI'] does not need to be filtered here as the path will be pulled from it in Cache_Enabler_Disk::get_cache_file_dir(). I think this was originally done due to the old, deprecated ce_action_cache_by_url_cleared action hook that used to be fired before the cache was cleared.

WordPress topic: https://wordpress.org/support/topic/blank-page-if-referrer-policy-directive-is-set/