-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On cache Miss of request containing "Range: bytes=0-" response status is 200 (should be 206) #4081
Comments
This is known, and it is unclear how this scenario could be improved at all. One of the questions is what would be a good value to send as |
I think you broke user agents because you tried to only enforce a 206, your snippet is lacking a a varnishtest "Emulate 206 on unbound bytes range"
server s1 {
rxreq
txresp -hdr "Transfer-Encoding: chunked" -hdr {etag: "123"}
chunked hello
delay 0.1
chunked world
chunkedlen 0
} -start
varnish v1 -vcl+backend {
import std;
sub vcl_deliver {
if (resp.is_streaming &&
std.tolower(req.http.range) == "bytes=0-" &&
req.http.if-none-match != resp.http.etag ) {
set resp.status = 206;
set resp.http.content-range = "bytes */*";
}
}
} -start
client c1 {
txreq -hdr "range: bytes=0-" -hdr {if-none-match: "abc"}
rxresp
expect resp.status == 206
expect resp.http.content-range == "bytes */*"
txreq -hdr "range: bytes=0-" -hdr {if-none-match: "def"}
rxresp
expect resp.status == 206
expect resp.http.content-range == "bytes 0-9/10"
} -run If you really really require a 206, maybe try the VCL snippet from this test case. |
For consistency with the non-streaming cases, we could consider replying with a 206 in this scenario. |
Does it help? If yes, 👍🏽 |
@imwhocodes did you get a chance to try the VCL workaround I suggested? sub vcl_deliver {
if (resp.is_streaming &&
std.tolower(req.http.range) == "bytes=0-" &&
req.http.if-none-match != resp.http.etag ) {
set resp.status = 206;
set resp.http.content-range = "bytes */*";
}
} |
Yes I did right after you proposed it, really appreciated! I was waiting to answer because it didn't solve the problem but I wanted to do more in-depth testing (that I didn't had time yet to do) As far from what I'm understanding/tested Chrome was not happy about, it actually like it more if I set something fake like Thanks |
@imwhocodes thank you for the additional feedback. For a streaming object, the range filter could wait for at least first-pos + x bytes and then send |
Expected Behavior
Given this condition:
Range: bytes=0-
Transfer-Encoding: chunked
While streaming from backend the response to the client should be:
206 (Partial Content)
Transfer-Encoding: chunked
Current Behavior
Given previous precondition:
While streaming from backend the response is:
200 (OK)
Transfer-Encoding: chunked
But when retrieving from cache (correctly):
206 (Partial Content)
Content-Length: ...
Content-Range: bytes ...
Possible Solution
I tried:
But this seem to break the response (at least on chrome)
Steps to Reproduce (for bugs)
No response
Context
I'm using Varnish as a reverse-proxy/cache in front of an aiohttp (python) server that encode on-demand some videos using ffmpeg, I want to minimize time form request to first frame out so ffmpeg output is piped out while it being processed:
ffmpeg ... -f mp4 -movflags frag_keyframe+empty_moov+default_base_moof pipe:
This is why the response from the origin/backend server is
Transfer-Encoding: chunked
The response is for a
<video> html5 tag
, 200 would be ok if not that Chrome misbehave (palyback seeking is broken) when not receiving 206 on aRange: bytes=0-
requestLog
Varnish Cache version
varnish:latest (varnish-7.4.2 revision cd1d10a)
Operating system
No response
Source of binary packages used (if any)
https://hub.docker.com/_/varnish
The text was updated successfully, but these errors were encountered: