Fix ETag 304 Not Modified by stripping W/ prefix from client header

Reverse proxy adds W/ prefix to ETags, but cache stores them without it.
Strip the prefix from client's If-None-Match header before comparing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-12-06 10:55:32 -06:00
parent 1308a89675
commit 3b448abcbd

View File

@@ -2,6 +2,7 @@ package handlers
import (
"net/http"
"strings"
"github.com/gin-gonic/gin"
"github.com/redis/go-redis/v9"
@@ -55,7 +56,8 @@ func (h *StaticDataHandler) GetStaticData(c *gin.Context) {
ctx := c.Request.Context()
// Check If-None-Match header for conditional request
clientETag := c.GetHeader("If-None-Match")
// Strip W/ prefix if present (added by reverse proxy, but we store without it)
clientETag := strings.TrimPrefix(c.GetHeader("If-None-Match"), "W/")
// Try to get cached ETag first (fast path for 304 responses)
if h.cache != nil && clientETag != "" {