Skip to content

Commit 89fd6db

Browse files
authored
Add 204 and 308 to heuristically cacheable status codes (#13015)
* Add 204 (No Content) and 308 (Permanent Redirect) to the heuristic caching allowlist in is_response_cacheable(), per RFC 9110 Section 15.1. * Add autest validating all seven RFC 9110 heuristically cacheable codes (200, 203, 204, 300, 301, 308, 410) are cached with only Last-Modified present, and non-cacheable codes (302, 307, 400, 403) are not.
1 parent 1c97530 commit 89fd6db

3 files changed

Lines changed: 537 additions & 1 deletion

File tree

src/proxy/http/HttpTransact.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6563,7 +6563,8 @@ HttpTransact::is_response_cacheable(State *s, HTTPHdr *request, HTTPHdr *respons
65636563
}
65646564

65656565
if ((response_code == HTTPStatus::OK) || (response_code == HTTPStatus::NOT_MODIFIED) ||
6566-
(response_code == HTTPStatus::NON_AUTHORITATIVE_INFORMATION) || (response_code == HTTPStatus::MOVED_PERMANENTLY) ||
6566+
(response_code == HTTPStatus::NON_AUTHORITATIVE_INFORMATION) || (response_code == HTTPStatus::NO_CONTENT) ||
6567+
(response_code == HTTPStatus::MOVED_PERMANENTLY) || (response_code == HTTPStatus::PERMANENT_REDIRECT) ||
65676568
(response_code == HTTPStatus::MULTIPLE_CHOICES) || (response_code == HTTPStatus::GONE)) {
65686569
TxnDbg(dbg_ctl_http_trans, "YES response code seems fine");
65696570
return true;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'''
2+
Test heuristic caching of status codes per RFC 9110 Section 15.1.
3+
'''
4+
# Licensed to the Apache Software Foundation (ASF) under one
5+
# or more contributor license agreements. See the NOTICE file
6+
# distributed with this work for additional information
7+
# regarding copyright ownership. The ASF licenses this file
8+
# to you under the Apache License, Version 2.0 (the
9+
# "License"); you may not use this file except in compliance
10+
# with the License. You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing, software
15+
# distributed under the License is distributed on an "AS IS" BASIS,
16+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# See the License for the specific language governing permissions and
18+
# limitations under the License.
19+
20+
Test.Summary = '''
21+
Test heuristic caching of status codes per RFC 9110 Section 15.1.
22+
23+
Verifies that responses with heuristically cacheable status codes (200, 203,
24+
204, 300, 301, 308, 410) are cached when only Last-Modified is present, and
25+
that non-cacheable codes (302, 307, 400, 403) are not.
26+
'''
27+
28+
Test.ATSReplayTest(replay_file="replay/cache-heuristic-status.replay.yaml")

0 commit comments

Comments
 (0)