ok, turns out I pasted the patch wrongly inside another if statement so it does work and 301/302 is no longer cached..
should be in function _can_cache2 :
function _can_cache2(&$buffer) {
/**
* Skip if caching is disabled
*/
if (!$this->_caching) {
return false;
}
/**
* Check for database error
*/
if (w3_is_database_error($buffer)) {
$this->cache_reject_reason = ‘Database error occurred’;
return false;
}
/**
* Check for DONOTCACHEPAGE constant
*/
if (defined(‘DONOTCACHEPAGE’) && DONOTCACHEPAGE) {
$this->cache_reject_reason = ‘DONOTCACHEPAGE constant is defined’;
return false;
}
/**
* Check hostname
*/
if ((!w3_is_multisite() || (w3_is_multisite() && !w3_force_master())) &&
$this->_config->get_boolean(‘pgcache.check.domain’) && w3_get_host() != w3_get_home_domain()) {
$this->cache_reject_reason = ‘Hostname mismatch’;
return false;
}
/**
* Don’t cache 404 pages
*/
if (!$this->_config->get_boolean(‘pgcache.cache.404’) && function_exists(‘is_404’) && is_404()) {
$this->cache_reject_reason = ‘Page is 404’;
return false;
}
/**
* Don’t cache homepage
*/
if (!$this->_config->get_boolean(‘pgcache.cache.home’) && function_exists(‘is_home’) && is_home()) {
$this->cache_reject_reason = is_front_page() && is_home() ? ‘Page is front page’ : ‘Page is posts page’;
return false;
}
/**
* Don’t cache front page
*/
if ($this->_config->get_boolean(‘pgcache.reject.front_page’) && function_exists(‘is_front_page’) && is_front_page() && !is_home()) {
$this->cache_reject_reason = ‘Page is front page’;
return false;
}
/**
* Don’t cache feed
*/
if (!$this->_config->get_boolean(‘pgcache.cache.feed’) && function_exists(‘is_feed’) && is_feed()) {
$this->cache_reject_reason = ‘Page is feed’;
return false;
}
/**
* Check if page contains dynamic tags
*/
if ($this->_enhanced_mode && $this->_has_dynamic($buffer)) {
$this->cache_reject_reason = ‘Page contains dynamic tags (mfunc or mclude) can not be cached in enhanced mode’;
return false;
}
/**
* Don’t cache redirects (301,302)
*/
if (in_array(http_response_code(),array(301,302)) ){
return false;
}
return true;
}