How to use Chrome's network debugger with redirects

前端 未结 4 1884
陌清茗
陌清茗 2020-11-30 16:28

The Chrome network debugger gives me a great view of all the HTTP resources loaded for a page. But it clears the list whenever a new top-level HTML page is loaded. This mak

相关标签:
4条回答
  • 2020-11-30 17:09

    This has been changed since v32, thanks to @Daniel Alexiuc & @Thanatos for their comments.


    Current (≥ v32)

    At the top of the "Network" tab of DevTools, there's a checkbox to switch on the "Preserve log" functionality. If it is checked, the network log is preserved on page load.

    Chrome v33 DevTools Network Tab: Preserve Log

    The little red dot on the left now has the purpose to switch network logging on and off completely.


    Older versions

    In older versions of Chrome (v21 here), there's a little, clickable red dot in the footer of the "Network" tab.

    Chrome v22 DevTools Network Tab: Preserve Log Upon Navigation

    If you hover over it, it will tell you, that it will "Preserve Log Upon Navigation" when it is activated. It holds the promise.

    0 讨论(0)
  • 2020-11-30 17:21

    I don't know of a way to force Chrome to not clear the Network debugger, but this might accomplish what you're looking for:

    1. Open the js console
    2. window.addEventListener("beforeunload", function() { debugger; }, false)

    This will pause chrome before loading the new page by hitting a breakpoint.

    0 讨论(0)
  • 2020-11-30 17:21

    Another great solution to debug the Network calls before redirecting to other pages is to select the beforeunload event break point

    This way you assure to break the flow right before it redirecting it to another page, this way all network calls, network data and console logs are still there.

    This solution is best when you want to check what is the response of the calls

    P.S: You can also use XHR break points if you want to stop right before a specific call or any call (see image example)

    0 讨论(0)
  • 2020-11-30 17:23

    Just update of @bfncs answer

    I think around Chrome 43 the behavior was changed a little. You still need to enable Preserve log to see, but now redirect shown under Other tab, when loaded document is shown under Doc.

    This always confuse me, because I have a lot of networks requests and filter it by type XHR, Doc, JS etc. But in case of redirect the Doc tab is empty, so I have to guess.

    0 讨论(0)
提交回复
热议问题