Zero byte chunked errors are not cached
Had a customer issue and started trying to reproduce it here and finally could using proxy verifier as an origin. If you return an error response, say 404, and have negative caching enabled for 404's, but then have the origin return that error as a chunked response with a 0 byte body then it is not actually cached or negative cached.
So there seems to be an issue with chunking and 0 byte responses
This can be reproduced using the negative-caching autest via this patch:
diff --git a/tests/gold_tests/cache/replay/negative-caching-300-second-timeout.replay.yaml b/tests/gold_tests/cache/replay/negative-caching-300-second-timeout.replay.yaml
index 7cb667b5e..a5cd7363b 100644
--- a/tests/gold_tests/cache/replay/negative-caching-300-second-timeout.replay.yaml
+++ b/tests/gold_tests/cache/replay/negative-caching-300-second-timeout.replay.yaml
@@ -52,8 +52,10 @@ sessions:
reason: "Not Found"
headers:
fields:
- - [ Content-Length, 32 ]
+ - [ Transfer-Encoding, chunked ]
- [ Cache-Control, max-age=300 ]
+ content:
+ size: 0
proxy-response:
status: 404
Test output:
$ ./autest.sh --sandbox /tmp/sb --clean=none -f negative-caching
Running Test negative-caching:......F Failed
Generating Report: --------------
Test: negative-caching: Failed
...
Run: Add a 404 response with explicit max-age=300 to the cache: Failed
Test : Checking that True == _isRunningAfter - Passed
Reason: Returned Value: True == _isRunningAfter
Starting TestRun 6-tr : No Issues found - Passed
Reason: Started!
Process: server-lifetime-cc: Passed
Setting up : Copying '/home/bneradt/src/ts_asf_master_negative_caching_chunked_body/build/proxy-verifier-v2.10.1/linux-arm64' to '/tmp/sb/negative-caching/server-lifetime-cc/bin' - Passed
Setting up : recycling port: 61038, queue size: 965 - Passed
Setting up : recycling port: 61039, queue size: 964 - Passed
Setting up : recycling port: 61040, queue size: 963 - Passed
Setting up : Copying '/home/bneradt/src/ts_asf_master_negative_caching_chunked_body/tests/gold_tests/autest-site/../../tools/proxy-verifier/ssl/server.pem' to '/tmp/sb/negative-caching/server-lifetime-cc/server.pem' - Passed
Setting up : Copying '/home/bneradt/src/ts_asf_master_negative_caching_chunked_body/tests/gold_tests/autest-site/../../tools/proxy-verifier/ssl/ca.pem' to '/tmp/sb/negative-caching/server-lifetime-cc/ca.pem' - Passed
Setting up : Copying 'replay/negative-caching-300-second-timeout.replay.yaml' to '/tmp/sb/negative-caching/server-lifetime-cc/negative-caching-300-second-timeout.replay.yaml' - Passed
Test : Checking that ReturnCode == 0 - Passed
Reason: Returned Value: 0 == 0
file /tmp/sb/negative-caching/_output/6-tr-server-lifetime-cc/stream.stdout.txt : There should be no Proxy Verifier violation errors. - Passed
Reason: Contents of /tmp/sb/negative-caching/_output/6-tr-server-lifetime-cc/stream.stdout.txt excludes expression
Process: Default: Failed
Setting up : Copying '/home/bneradt/src/ts_asf_master_negative_caching_chunked_body/build/proxy-verifier-v2.10.1/linux-arm64' to '/tmp/sb/negative-caching/client-lifetime-cc/bin' - Passed
Setting up : Copying 'replay/negative-caching-300-second-timeout.replay.yaml' to '/tmp/sb/negative-caching/client-lifetime-cc/negative-caching-300-second-timeout.replay.yaml' - Passed
Setting up : Copying '/home/bneradt/src/ts_asf_master_negative_caching_chunked_body/tests/gold_tests/autest-site/../../tools/proxy-verifier/ssl/client.pem' to '/tmp/sb/negative-caching/client-lifetime-cc/client.pem' - Passed
Setting up : Copying '/home/bneradt/src/ts_asf_master_negative_caching_chunked_body/tests/gold_tests/autest-site/../../tools/proxy-verifier/ssl/ca.pem' to '/tmp/sb/negative-caching/client-lifetime-cc/ca.pem' - Passed
Test : Checking that ReturnCode == 0 - Failed
Reason: Returned Value 1 != 0
file /tmp/sb/negative-caching/_output/6-tr-Default/stream.stdout.txt : There should be no Proxy Verifier violation errors. - Failed
Reason: Contents of /tmp/sb/negative-caching/_output/6-tr-Default/stream.stdout.txt contains expression: "Violation|Invalid status"
Details:
[ERROR]: HTTP/1 Status Violation: expected 404 got 200, key: 22 : 49
Run: Wait for cached object to be stale if lifetime is incorrectly used.: Skipped
Reason: Test run 6-tr failed
Run: Make sure object is fresh: Skipped
Reason: Test run 6-tr failed
Total of 1 test
Unknown: 0
Exception: 0
Failed: 1
Warning: 0
Skipped: 0
Passed: 0
I notice that this seems to also be an issue for non-negative responses as well. That is, if I modify the Proxy Verifier origin to return a 200 OK with a 0 byte chunked body, a second request for that same object also doesn't get served out of cache either.