Sub topic 6
Reading the Network panel
This chapter assumes you can open DevTools and move between panels, and that you know the basics of HTTP: methods, status codes, headers, and the request and response cycle. You should also know roughly how a browser loads a page: it fetches HTML, discovers more resources, and fetches those too.
The Network panel records every request the page makes while DevTools is open. It shows what was asked for, what came back, and how long each stage took. Use it when a page loads slowly, an API call fails, a file is not cached, or the wrong data reaches the server.
Recording requests
The panel records only while DevTools is open. Requests made before you opened it are missing. To capture them, open the panel and reload the page.
The toolbar has these controls:
- Record (a round button). Turns logging on or off.
- Clear. Empties the list so you can isolate one action.
- Preserve log. Keeps entries across navigations. Turn it on when you debug a redirect, a form post that reloads the page, or a login flow.
- Disable cache. Bypasses the HTTP cache while DevTools is open. Turn it on to measure a cold load. Turn it off to see what a returning visitor gets.
- Throttling. Simulates a slower connection. Chapter 8 covers it.
- Filter box and type buttons. Narrow the list. See the next section.
A good habit is to clear the log, perform exactly one action in the page, and then read only the requests that action produced.
Reading the request list
Each row is one request. The default columns are:
| Column | What it tells you |
|---|---|
| Name | The last part of the URL. Hover to see the full URL. |
| Status | The HTTP status code, or a browser-side state such as `(failed)` or `(canceled)`. |
| Type | The resource type, such as `document`, `script`, `stylesheet`, `fetch`, `xhr`, `image`, `font`. |
| Initiator | What caused the request: the HTML parser, a script line, or another file. |
| Size | Bytes transferred over the network, and below it the size of the uncompressed body. |
| Time | Total time from start to finish. |
| Waterfall | A bar per request showing when each phase happened. |
Right-click the column header to add more columns, such as Protocol, Domain, Remote Address, or Priority.
The Size column
Size shows two numbers. The top number is what crossed the network, which includes headers and compression. The bottom number is the size of the resource after decompression. A large gap means compression is working. If both numbers match for a text file such as JavaScript or CSS, the server probably is not compressing it.
Size can also show a cache source instead of a number:
(memory cache): served from RAM within the current page session.(disk cache): served from the browser's stored files, with no network request.(ServiceWorker): answered by a service worker.
A request that was revalidated with the server and answered 304 Not Modified appears with a small size, because only headers crossed the network.
The Initiator column
Initiator answers the question "why was this requested?" Click the link in the column to jump to the line of code that started the request. Hover over it to see the call stack. This is the fastest way to find which script sent an unexpected API call.
Filtering and searching
The type buttons above the list (Fetch/XHR, JS, CSS, Img, Media, Font, Doc, WS, Wasm, Manifest, Other) show one kind of resource at a time. Fetch/XHR is the one you will use most when debugging an application that talks to an API.
The filter box accepts plain text and several operators. These are the most useful:
| Filter | Effect |
|---|---|
| `api/users` | Shows requests whose URL contains the text. |
| `-.png` | Hides requests that match. |
| `status-code:404` | Shows only requests with that status. |
| `method:POST` | Shows only that HTTP method. |
| `domain:cdn.example.com` | Shows only that host. |
| `larger-than:100k` | Shows responses over 100 kilobytes. |
| `is:running` | Shows requests still in progress. |
| `has-response-header:set-cookie` | Shows requests whose response sets a cookie. |
Press Ctrl+F (or Cmd+F on macOS) inside the panel to search the content of headers and response bodies, not only URLs. This finds which request returned a particular value.
Inspecting a single request
Click a row to open its detail pane. These tabs matter most.
Headers
The Headers tab has three groups: General, Response Headers, and Request Headers.
- General shows the full URL, the method, the status code, and the remote address.
- Request Headers shows what the browser sent:
Accept,Cookie,Authorization,Origin,User-Agent, and so on. - Response Headers shows what the server returned:
Content-Type,Cache-Control,Set-Cookie,Content-Encoding,Access-Control-Allow-Origin, and so on.
When a header is wrong, compare the request and the response. For example, a missing login often shows up as an absent Cookie request header, and the cause is usually visible in an earlier Set-Cookie response header that carried a SameSite, Secure or Domain attribute that blocked it.
Payload
For POST, PUT and PATCH requests, the Payload tab shows what the browser sent. For query strings, it lists each parameter. For JSON bodies, it shows the parsed object, and you can toggle between the parsed view and the source. Check here when the server says a field is missing: the problem is often in what the client sent, not in the server.
Preview and Response
Response shows the raw body. Preview renders it: JSON as an expandable tree, images as images, HTML as a page. If JSON looks wrong in Preview but the raw text is fine, check the Content-Type header.
Timing
The Timing tab breaks one request into phases:
| Phase | Meaning |
|---|---|
| Queueing | The browser waited before sending. It may have hit the limit of parallel connections per host, or the request had lower priority. |
| Stalled | Time blocked after queueing, before the request could start. |
| DNS Lookup | Resolving the host name to an IP address. |
| Initial connection | Opening the TCP connection. |
| SSL | The TLS handshake, part of the connection time. |
| Request sent | Sending the request. Usually tiny. |
| Waiting for server response | Time to first byte (TTFB): from sending until the first byte of the reply arrives. |
| Content Download | Receiving the body. |
The key reading rule: look for the longest phase.
- A long Waiting for server response points at a slow server or backend. Making the file smaller will not help.
- A long Content Download points at a large body or a slow connection. Compression or a smaller payload will help.
- Long DNS, Initial connection or SSL appear on the first request to a host. A later request on a reused connection shows none of them.
- Long Queueing with many requests to one host suggests too many parallel requests.
Reading the waterfall
The Waterfall column draws every request on a shared time axis. Each bar is split into colored phases that match the Timing tab. Hover a bar to see the breakdown.
Read the waterfall for shape, not detail:
- A staircase, where each request starts only after the previous one ends, means a dependency chain. A script loads a second script, which loads a third. Break the chain by preloading or bundling.
- A wide wall of simultaneous bars means many parallel requests. If they are all stalled, the connection limit is the bottleneck.
- A long gap before the first bar means the HTML itself was slow.
- Blue and red vertical lines mark the
DOMContentLoadedandloadevents. Resources that finish after them did not block those events.
Because DNS, connection and TLS happen only when a new connection is needed, a request that reuses an open connection skips straight from queueing to the request being sent.
Status codes and failures
Sort the Status column or filter by status-code: to find problems quickly. Colors help too: failed requests are drawn in red.
| Status | Typical meaning | What to check |
|---|---|---|
| `200` | Success | Whether the body is what you expected. |
| `204` | Success, no body | Normal for some updates and for CORS preflights. |
| `301` / `302` | Redirect | The `Location` response header. Chains of redirects add delay. |
| `304` | Not modified | The cache revalidation worked. |
| `401` / `403` | Not authenticated / not allowed | The `Authorization` and `Cookie` request headers. |
| `404` | Not found | The exact URL, including path and case. |
| `429` | Too many requests | Retry headers and request volume. |
| `500` / `502` / `503` | Server error | The response body and server logs. DevTools cannot show the cause. |
Some failures have no status code, because no HTTP response ever arrived:
(failed) net::ERR_CONNECTION_REFUSEDorERR_NAME_NOT_RESOLVED: the connection or DNS step failed.(blocked:mixed-content): an HTTPS page tried to load an HTTP resource.(blocked:csp): a Content Security Policy forbade the request.(canceled): the page or the browser abandoned the request, for example when a script aborted afetchor the user navigated away. It is not always an error.- A CORS failure: the Console prints the reason. In the Network panel, the request often shows as
(failed)or with a status of0, and the real cause is the missingAccess-Control-Allow-Originheader. Look for an earlierOPTIONSpreflight request and check its response headers.
Checking caching
Caching decisions come from response headers. In the Headers tab, look for:
Cache-Control, for examplemax-age=31536000, immutablefor fingerprinted assets, orno-storefor sensitive data.ETagandLast-Modified, which let the browser revalidate withIf-None-MatchorIf-Modified-Since.Content-Encoding, such asgziporbr, which shows compression.
To test cache behavior, turn Disable cache off, load the page, then reload it normally. Compare the Size column on the second load. Static files should say (disk cache) or (memory cache), or show a 304. If a file that never changes downloads in full each time, it has no usable caching headers.
Also remember that a hard reload and a normal reload differ. A hard reload ignores the cache for that load. Measure with the setting that matches the user you care about.
Replaying and exporting requests
Right-click a request for several useful options:
- Copy as cURL (or Copy as fetch) copies the request, with its headers and body, so you can replay it from a terminal or the Console. This helps you reproduce a bug without the page.
- Replay XHR sends the same request again.
- Save all as HAR exports the whole log as a HAR file (HTTP Archive, a JSON format). You can attach it to a bug report or load it into other tools.
- Block request URL makes the browser refuse that URL. Use it to test how the page behaves when a script, font or API is unavailable.
// Paste a request copied with "Copy as fetch" into the Console, then
// change one value to test how the server responds.
fetch('/api/users?limit=5', {
headers: { Accept: 'application/json' },
credentials: 'same-origin'
})
.then((response) => {
console.log(response.status, response.headers.get('content-type'));
return response.json();
})
.then((data) => console.table(data))
.catch((error) => console.error('Request failed:', error));A repeatable workflow
When something is wrong with loading or an API call:
- Open the Network panel, turn on Preserve log if the page navigates, and clear the list.
- Repeat the action that fails, once.
- Filter to Fetch/XHR or the relevant type, or filter by status code.
- Click the failing request. Check Status, then Headers, then Payload.
- Compare what was sent against what the server needed. Compare the response against what the code expected.
- If the problem is speed, open Timing and find the longest phase. Then check the waterfall for chains and the Size column for uncompressed or uncached files.
- Change one thing and repeat from step 2, so you know which change mattered.
Common mistakes
- Opening DevTools after the page loaded, then wondering why requests are missing. Reload with the panel open.
- Judging load speed with Disable cache on, or off, without noticing which one you used.
- Blaming the network for a slow page when Timing shows most of the time in Waiting for server response.
- Reading a
(canceled)request as a bug. Check the Initiator and whether the page replaced it with a newer request. - Forgetting that a service worker can answer requests. If Size says
(ServiceWorker), the request may never have touched the network. Chapter 7 covers service workers. - Sharing HAR files without removing credentials.
Exercise
A page's API call takes 2.4 seconds. In the Timing tab, Waiting for server response is 2.3 seconds, Content Download is 20 ms, and DNS, connection and SSL are all absent. Where is the time going, and which two explanations can you rule out?
Show answer
The time is spent on the server, between the request being sent and the first byte of the reply arriving (TTFB). You can rule out a large response body, because Content Download is only 20 ms. You can also rule out connection setup, because DNS, connection and SSL are absent, which means the browser reused an open connection. The next step is to look at the backend: the query, the processing, or an upstream call.
Exercise
A fetch call from your page to https://api.example.com shows (failed) in the Network panel, and the Console mentions a missing Access-Control-Allow-Origin header. What would you check in the Network panel, and where does the fix belong?
Show answer
Filter by the domain and look for an OPTIONS preflight request. Check its response headers, and the headers of the actual request if it was sent, for Access-Control-Allow-Origin and related CORS headers. The fix belongs on the server at api.example.com, which must send the right CORS headers for your page's origin. Changing the client code will not fix it.