Validation doesn't work
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- go
- Lĩnh vực
- backend, performance
Hướng nghiên cứu
Bắt đầu bằng cách chạy bản tái hiện Caddyfile và so sánh request upstream được thực hiện bởi hai lệnh curl. Theo dõi điểm vào của quá trình xác thực/tái xác thực cache trong module Go và xác minh rằng metadata Last-Modified đã lưu được gửi dưới dạng request có điều kiện; hoàn thành có nghĩa là upstream nhận được điều kiện và hành vi của response khớp với việc xác thực HTTP.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
According to clause No. 4.3 of RFC 7234:
4.3. Validation
When a cache has one or more stored responses for a requested URI, but cannot serve any of them (e.g., because they are not fresh, or one cannot be selected; see Section 4.1), it can use the conditional request mechanism
...
This process is known as "validating" or "revalidating" the stored response.
4.3.1. Sending a Validation Request
When sending a conditional request for cache validation, a cache sends one or more precondition header fields containing validator metadata from its stored response(s), which is then compared by recipients to determine whether a stored response is equivalent to a current representation of the resource.
One such validator is the timestamp given in a Last-Modified header field...
Another validator is the entity-tag given in an ETag header field...
Thus, I expect caddy to cache the first response and subsequently validate cached data via a conditional request. However, caddy simply forwards a request to an upstream without any conditions.
I've tested it only with Last-Modified and no-cache, because of the bug I noticed with ETag. Additionally, I couldn't trigger revalidation using other directives like must-revalidate and stale-while-revalidate.
Reproduction steps:
{
log
cache {
stale 60s
}
}
http://localhost:80 {
log
cache
reverse_proxy http://localhost:81
}
http://localhost:81 {
log
header Last-Modified "Mon, 15 Dec 2025 08:52:20 GMT"
header Cache-Control "no-cache"
respond "Hello world"
}
$ curl -ik localhost:80
HTTP/1.1 200 OK
Cache-Control: no-cache
Cache-Status: Souin; fwd=uri-miss; stored; key=GET-http-localhost-/
Last-Modified: Mon, 15 Dec 2025 08:52:20 GMT
...
$ curl -ik localhost:80
HTTP/1.1 200 OK
Cache-Control: no-cache
Cache-Status: Souin; fwd=request; fwd-status=200; key=GET-http-localhost-/; detail=REQUEST-REVALIDATION
Last-Modified: Mon, 15 Dec 2025 08:52:20 GMT
...
logs:
{"level":"info","ts":1766736377.4338582,"logger":"http.log.access","msg":"handled request","request":{"remote_ip":"127.0.0.1","remote_port":"48850","client_ip":"127.0.0.1","proto":"HTTP/1.1","method":"GET","host":"localhost","uri":"/","headers":{"X-Forwarded-Proto":["http"],"Accept-Encoding":["gzip"],"Accept":["*/*"],"Date":["Fri, 26 Dec 2025 08:06:17 UTC"],"Via":["1.1 Caddy"],"X-Forwarded-Host":["localhost"],"User-Agent":["curl/8.7.1"],"X-Forwarded-For":["172.16.249.1"]}},"bytes_read":0,"user_id":"","duration":0.000199667,"size":11,"status":200,"resp_headers":{"Content-Type":["text/plain; charset=utf-8"],"Server":["Caddy"],"Last-Modified":["Mon, 15 Dec 2025 08:52:20 GMT"],"Cache-Control":["no-cache"]}}
{"level":"info","ts":1766736377.4560177,"logger":"http.log.access","msg":"handled request","request":{"remote_ip":"172.16.249.1","remote_port":"57879","client_ip":"172.16.249.1","proto":"HTTP/1.1","method":"GET","host":"localhost","uri":"/","headers":{"User-Agent":["curl/8.7.1"],"Accept":["*/*"]}},"bytes_read":0,"user_id":"","duration":0.023146958,"size":11,"status":200,"resp_headers":{"Last-Modified":["Mon, 15 Dec 2025 08:52:20 GMT"],"Server":["Caddy"],"Content-Length":["11"],"Via":["1.1 Caddy"],"Date":["Fri, 26 Dec 2025 08:06:17 GMT"],"Cache-Control":["no-cache"],"Content-Type":["text/plain; charset=utf-8"],"Cache-Status":["Souin; fwd=uri-miss; stored; key=GET-http-localhost-/"]}}
{"level":"info","ts":1766736406.6892934,"logger":"http.log.access","msg":"handled request","request":{"remote_ip":"127.0.0.1","remote_port":"48850","client_ip":"127.0.0.1","proto":"HTTP/1.1","method":"GET","host":"localhost","uri":"/","headers":{"X-Forwarded-For":["172.16.249.1"],"X-Forwarded-Host":["localhost"],"X-Forwarded-Proto":["http"],"Accept":["*/*"],"Date":["Fri, 26 Dec 2025 08:06:46 UTC"],"Via":["1.1 Caddy"],"Accept-Encoding":["gzip"],"User-Agent":["curl/8.7.1"]}},"bytes_read":0,"user_id":"","duration":0.000023417,"size":11,"status":200,"resp_headers":{"Server":["Caddy"],"Last-Modified":["Mon, 15 Dec 2025 08:52:20 GMT"],"Cache-Control":["no-cache"],"Content-Type":["text/plain; charset=utf-8"]}}
{"level":"info","ts":1766736406.6932402,"logger":"http.log.access","msg":"handled request","request":{"remote_ip":"172.16.249.1","remote_port":"57892","client_ip":"172.16.249.1","proto":"HTTP/1.1","method":"GET","host":"localhost","uri":"/","headers":{"Accept":["*/*"],"User-Agent":["curl/8.7.1"]}},"bytes_read":0,"user_id":"","duration":0.019553791,"size":11,"status":200,"resp_headers":{"Content-Length":["11"],"Last-Modified":["Mon, 15 Dec 2025 08:52:20 GMT"],"Via":["1.1 Caddy"],"Cache-Control":["no-cache"],"Content-Type":["text/plain; charset=utf-8"],"Cache-Status":["Souin; fwd=request; fwd-status=200; key=GET-http-localhost-/; detail=REQUEST-REVALIDATION"],"Server":["Caddy"],"Date":["Fri, 26 Dec 2025 08:06:46 GMT"]}}
As we may see, the request made by caddy is not conditional.
- Ngôn ngữ chính
- Go
- Star
- 396
- Fork
- 29
- Merge trung bình
- 32 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của caddyserver/cache-handler
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
caddyserver/cache-handler#138 · 1 bình luận · 3 reaction ·
-
Admin API purge/invalidation still panics with nil pointer on v0.16.0 (same root cause as #140)Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
caddyserver/cache-handler#143 · 2 bình luận ·
-
Can not flush cacheĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
caddyserver/cache-handler#140 · 4 bình luận · 1 reaction ·
-
`Incomming` has a typoĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 45/100
caddyserver/cache-handler#139 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
caddyserver/cache-handler#137 · 1 bình luận ·
Tất cả issue của caddyserver/cache-handler
Issue tương tự
-
area/tests theme/ci-dx
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs triage pkg/translator/faro
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
open-telemetry/opentelemetry-collector-contrib#51759 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
appbaseio/reactivesearch-api#402 ·
-
GET /api/v1/system/api_keys returns the full API token in plaintextCó thể đã có người làm @Harsh23Kashyap đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
infiniflow/ragflow#20555 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày