Skip to content
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

Clarify what transferSize, encodedBodySize should return in various conditions #40

Closed
valenting opened this issue Oct 14, 2015 · 5 comments · Fixed by #41
Closed

Clarify what transferSize, encodedBodySize should return in various conditions #40

valenting opened this issue Oct 14, 2015 · 5 comments · Fixed by #41

Comments

@valenting
Copy link

Since we also return resource timing entries for cached resources, it should be specified if transferSize should return the same value it had during the first load, or just an estimation (body+headers).

Secondly, since we sometimes get 4XX/5XX responses with content, it needs to be clarified how we handle this case. I assume it would still return non-zero values, even if this is not the body of the resource we requested?

Also, while usually encodedBodySize is the same as the Content-Length response header, in some cases it could differ. I assume we want the actual number of bytes on the wire.

@valenting
Copy link
Author

Also, is it correct if the transferSize is smaller than encodedBodySize in cases where the resource is cached, but we hit the network in order to revalidate, and transferSize is the size of the headers?

@igrigorik
Copy link
Member

Great feedback, we do need to clarify this stuff in the spec. Before I do though...

Since we also return resource timing entries for cached resources, it should be specified if transferSize should return the same value it had during the first load, or just an estimation (body+headers).

transferSize should be set to 0 when response comes from cache; it's meant as an explicit signal that resource was fetched from the network.

Secondly, since we sometimes get 4XX/5XX responses with content, it needs to be clarified how we handle this case. I assume it would still return non-zero values, even if this is not the body of the resource we requested?

Right. It should return the sum of response headers and response payload body, regardless of response code (2xx, 3xx, 4xx, 5xx, ...)

Also, while usually encodedBodySize is the same as the Content-Length response header, in some cases it could differ. I assume we want the actual number of bytes on the wire.

Correct. Content-Length is also not guaranteed to be present.. so we want to report the actual number of bytes the client received.

Also, is it correct if the transferSize is smaller than encodedBodySize in cases where the resource is cached, but we hit the network in order to revalidate, and transferSize is the size of the headers?

  • If valid response comes from cache: transferSize should be set to 0, encodedBodySize should be the size of the cached payload body before any content-codings are removed.
  • If a revalidation happens: transferSize should report the size of response headers (there is no body to account for), and encodedBodySize should be the size of the cached payload body before any content-codings are removed.

Does that make sense?

@valenting
Copy link
Author

Yes, this sounds like a sane behaviour for the spec.
Thanks!

igrigorik added a commit that referenced this issue Oct 20, 2015
- spell out cache vs network fetch behavior
- notes for non-2xx responses

closes #40
@igrigorik
Copy link
Member

@valenting ptal at #41.

@taxi666
Copy link

taxi666 commented Apr 10, 2019

Why encodedBodySize is 0 sometimes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants