[wp-trac] [WordPress Trac] #3027: 404 error pages should be forced
to not cache
WordPress Trac
wp-trac at lists.automattic.com
Fri Aug 11 07:21:34 GMT 2006
#3027: 404 error pages should be forced to not cache
-------------------------+--------------------------------------------------
Reporter: _ck_ | Owner: anonymous
Type: enhancement | Status: new
Priority: low | Milestone: 2.1
Component: Template | Version: 2.0.4
Severity: minor | Keywords:
-------------------------+--------------------------------------------------
I am not certain if this is an internal WP issue but it should at least be
used/demonstrated in the default theme 404.php template (more accurately,
the header since that's where it has to be fixed).
WP sets regular headers for the 404 error page and this causes most
browsers to cache it. So if someone adds a post or fixes whatever issue
that cause the url to be invalid, the error doesn't go away unless they
realize they need a hard refresh (an easy oversight).
The following code example will prevent the issue in the template
header.php but there may be a better way to do it?
{{{
<?
if (is_404()) {
header("HTTP/1.1 404 Not Found");
header ("Pragma: no-cache"); // HTTP 1.0
header ("Expires: Mon, 25 Jul 1995 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always
modified
header ("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP 1.1
header ("Cache-Control: post-check=0, pre-check=0", false); // HTTP 1.1
// echo "\n<!--\n"; print_r($_REQUEST); echo "\n-->\n";
}
?>
}}}
--
Ticket URL: <http://trac.wordpress.org/ticket/3027>
WordPress Trac <http://wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list