- commit
- 54c886f
- parent
- 0a4c670
- author
- Eric Bower
- date
- 2026-04-20 19:39:46 -0400 EDT
fix(httpcache): verified heuristically cachable status codes
1 files changed,
+9,
-7
+9,
-7
1@@ -434,15 +434,17 @@ func isResponseCachable(r *http.Request, resp *responseWriter) error {
2 return nil
3 }
4
5-// isCacheableStatusCode checks if the status code is cacheable per RFC 9110 Section 15.1-2
6-// RFC 9110 15.1-2: 200, 203, 204, 206, 300, 301, 308, 404, 405, 410, 414, and 501.
7+// RFC 9110 15.1-2: Heuristically cachable status codes
8+// 200, 203, 204,
9+// 206, 300, 301,
10+// 308, 404, 405,
11+// 410, 414, 501.
12 func isCacheableStatusCode(code int) bool {
13 switch code {
14- case http.StatusOK, http.StatusMultipleChoices, http.StatusMovedPermanently, http.StatusFound,
15- http.StatusSeeOther, http.StatusUseProxy, http.StatusTemporaryRedirect,
16- http.StatusPermanentRedirect, http.StatusPartialContent, http.StatusMultiStatus,
17- http.StatusAlreadyReported, http.StatusIMUsed, http.StatusNotImplemented, http.StatusBadGateway,
18- http.StatusServiceUnavailable, http.StatusGatewayTimeout, http.StatusHTTPVersionNotSupported:
19+ case http.StatusOK, http.StatusNonAuthoritativeInfo, http.StatusNoContent,
20+ http.StatusPartialContent, http.StatusMultipleChoices, http.StatusMovedPermanently,
21+ http.StatusPermanentRedirect, http.StatusNotFound, http.StatusMethodNotAllowed,
22+ http.StatusGone, http.StatusRequestURITooLong, http.StatusNotImplemented:
23 return true
24 default:
25 return false