cache-handler: Missing response on cached paths

Cache misses on first request and hits on next, that’s fine. But I no longer receive a response from the endpoint.

This is my Caddyfile.

{
	order cache before rewrite
	cache
}

:{$APP_PORT} {
	handle_path /api/* {
		reverse_proxy http://localhost:{$SERVER_PORT} {
			transport http {
				versions h2c
			}
		}
	}

	handle_path /api/v1/translate {
		cache {
			allowed_http_verbs POST
			ttl 24h
		}
	}
}

Logs from cURL.

*   Trying [::1]:7861...
* Connected to localhost (::1) port 7861
> POST /api/v1/translate? HTTP/1.1
> Host: localhost:7861
> User-Agent: curl/8.3.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 97
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Cache-Control:
Cache-Control:
< Cache-Status: Souin; fwd=uri-miss; stored; key=POST-http-localhost:7861--718c30564a9d539ac393940896d588a095e1b2e1dea02edb7d36e62d9d40f757
Cache-Status: Souin; fwd=uri-miss; stored; key=POST-http-localhost:7861--718c30564a9d539ac393940896d588a095e1b2e1dea02edb7d36e62d9d40f757
< Server: Caddy
Server: Caddy
< Date: Tue, 19 Sep 2023 21:05:15 GMT
Date: Tue, 19 Sep 2023 21:05:15 GMT
< Content-Length: 0
Content-Length: 0

Logs from Caddy

{
  "level":"info","ts":1695157539.7626615,
  "logger":"http.handlers.cache",
  "msg":"Serve from cache &{Method:POST URL:? Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Accept:[*/*] Content-Length:[97] Content-Type:[application/json] Date:[Tue, 19 Sep 2023 21:05:39 UTC] User-Agent:[curl/8.3.0]] Body:{Reader:{\n         \"text\": \"world!\",\n         \"source\": \"eng_Latn\",\n         \"target\": \"spa_Latn\"\n      }} GetBody:<nil> ContentLength:97 TransferEncoding:[] Close:false Host:localhost:7861 Form:map[] PostForm:map[] MultipartForm:<nil> Trailer:map[] RemoteAddr:172.17.0.1:45620 RequestURI:/? TLS:<nil> Cancel:<nil> Response:<nil> ctx:0xc000201a40}"
}

About this issue

  • Original URL
  • State: open
  • Created 9 months ago
  • Comments: 22 (5 by maintainers)

Most upvoted comments

You’re probably right, I will check if the body is put again in the request after we read it to generate the body hash.