- commit
- 3ad9fce
- parent
- d758032
- author
- Eric Bower
- date
- 2026-04-19 11:40:18 -0400 EDT
chore(pgs): HEAD can share same key as GET
2 files changed,
+13,
-2
+6,
-1
1@@ -35,7 +35,12 @@ type PgsCacheKey struct {
2
3 func (c *PgsCacheKey) GetCacheKey(r *http.Request) string {
4 subdomain := router.GetSubdomainFromRequest(r, c.Domain, c.TxtPrefix)
5- return subdomain + "__" + r.Method + "__" + r.URL.RequestURI()
6+ // RFC 9111 §3: HEAD responses can be served from a stored GET response.
7+ method := r.Method
8+ if method == http.MethodHead {
9+ method = http.MethodGet
10+ }
11+ return subdomain + "__" + method + "__" + r.URL.RequestURI()
12 }
13
14 type PromCacheMetrics struct {
+7,
-1
1@@ -19,7 +19,13 @@ type CacheKey interface {
2 type DefaultCacheKey struct{}
3
4 func (p *DefaultCacheKey) GetCacheKey(r *http.Request) string {
5- return r.Host + "__" + r.Method + "__" + r.URL.RequestURI()
6+ // RFC 9111 §3: HEAD responses can be served from a stored GET response.
7+ // Normalize HEAD to GET so both methods share the same cache entry.
8+ method := r.Method
9+ if method == http.MethodHead {
10+ method = http.MethodGet
11+ }
12+ return r.Host + "__" + method + "__" + r.URL.RequestURI()
13 }
14
15 type CacheMetrics interface {