Redundant `Expires` and invalid `FilesMatch`
-
It seems that the following code can be improved.
Expires
is ignored whenmax-age
is present and so should be removed.if ( $this->main_instance->get_single_config( 'cf_bypass_sitemap', 0 ) > 0 && $this->is_cache_enabled() ) {
$htaccess_lines[] = '<IfModule mod_expires.c>';
$htaccess_lines[] = 'ExpiresActive on';
$htaccess_lines[] = 'ExpiresByType application/xml "access plus 0 seconds"';
$htaccess_lines[] = 'ExpiresByType text/xsl "access plus 0 seconds"';
$htaccess_lines[] = '</IfModule>';
$htaccess_lines[] = '<FilesMatch "\.(xml|xsl)$">';
$htaccess_lines[] = '<IfModule mod_headers.c>';
$htaccess_lines[] = 'Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"';
$htaccess_lines[] = '</IfModule>';
$htaccess_lines[] = '</FilesMatch>';
}And since sitemap files are generated dynamically by WP Core and most plugins,
<FilesMatch>
being a filesystem container can’t really locate them and should be replaced by something likeHeader set Cache-Control "no-cache, no-store, must-revalidate, max-age=0" "expr=%{CONTENT_TYPE} =~ m#(?:application/xml|text/xsl)#"
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.