Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When Drupal serves an error page from cache, it returns 304 as status code if headers if-modified-since and if-none-match match expected values, as defined in includes/bootstrap.inc
function drupal_serve_page_from_cache(stdClass $cache) {
// ...
// See if the client has provided the required HTTP headers.
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
$if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE;
if ($if_modified_since && $if_none_match
&& $if_none_match == $etag // etag must match
&& $if_modified_since == $cache->created) { // if-modified-since must match
header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
drupal_send_headers($default_headers);
return;
}
// ...
From W3 specifications about If-None-Match header:
If the request would, without the If-None-Match header field, result in anything other than a 2xx or 304 status, then the If-None-Match header MUST be ignored.
So cached status code must be checked, and this block must be skipped for 4xx status codes.
Comment | File | Size | Author |
---|---|---|---|
#3 | core-304_cached_error_pages-2579005-3.patch | 2.04 KB | Cinedin |
Comments
Comment #2
Cinedin CreditAttribution: Cinedin commentedComment #3
Cinedin CreditAttribution: Cinedin commentedComment #4
Cinedin CreditAttribution: Cinedin commentedComment #5
cilefen CreditAttribution: cilefen commentedI moved this to Normal priority for now and removed tags that do not clarify the issue.
Please check if this is an issue with Drupal 8. If so, it must be fixed there first according to the backport policy. If it is, move it to branch 8.0.x-dev and tag it “Needs backport to D7”.