Skip to content

Network: HTTP Request to resource cached previously would not consider range header when constructing response after revalidation. #40050

@rayguo17

Description

@rayguo17

Describe the bug:
Current http cache would reconstruct cached response if cache exist but need revalidation after validating it as not modified, but will not consider the range header when constructing the response again.

To Reproduce:

  1. Setup HTTP server using nginx, using below configuration:
server {
    listen 80;
    server_name example.com;

    location / {
        root /var/www/html
        add_header age 51608;
    }
}

Note: here the purpose of adding 'age' header is to simulate the scenario that the resource that we are fetching is being cached in proxy for more than 24 hours.
2. place fetch.html, and big file (e.g. video file) under /var/www/html, the content of the fetch.html is as below:

<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
    fetch script!
    <button id="whole">Fetch Whole</button>
    <button id="partial">Fetch Partial</button>
    <script>
        const url = "mossel_giftbox.mp4"
        let btnWhole = document.getElementById("whole");
        btnWhole.onclick = async () => {
            const response = await fetch(url);
            const blob = await response.blob();
            console.log("Fetched whole blob:", blob.size);
        }
        let btnPartial = document.getElementById("partial");
        btnPartial.onclick = async () => {
            const response = await fetch(url, { headers: { Range: "bytes=0-1024" } });
            const blob = await response.blob();
            console.log("Fetched partial blob:", blob.size);
        }
    </script>
</body>
</html>
  1. Try press the Fetch Whole button, wait until the fetch request is finished, and the log is shown.
  2. Press the Fetch Partial button, observe the log.
Chromium Behaviour Servo Behavior
Fetched Whole blob: 35768068 Fetched Whole blob: 35768068
Fetched Partial blob: 1024 Fetched Partial blob: 35768068

Platform:
Tested on Ubuntu 24.04

Metadata

Metadata

Assignees

Labels

A-networkC-assignedThere is someone working on resolving the issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions