Chrome Extension Not Capturing Cached Requests from In-Memory Cache

Skip to first unread message

John Hansfeldt

May 27, 2024, 7:04:33 PMMay 27
to Chromium Extensions
I'm developing a Chrome extension that reads and displays requests from various marketing platforms (e.g., Facebook Pixel, Google Ads, LinkedIn, GA4 etc.) by using the chrome.webRequest API. While my extension works well for most requests, I encounter an issue with requests that are served from Chrome's in-memory cache(often from service workers).

When requests are answered from Chrome's in-memory cache, they do not appear in my extension. This is problematic because I need to capture and process these requests for accurate data tracking and display. Despite being visible in the browser's Network tab, these cached requests are invisible to the webRequest API.

I have read the documentation and think i understand that the limitation probably is the webRequest API itself but i have also tried various attempts with DNR(declarativeNetRequest )but has not worked so far. Has anyone solved this themself and how?

Cuyler Stuwe

May 27, 2024, 8:15:05 PMMay 27
to John Hansfeldt, Chromium Extensions
Yeah, there's a difference between just "cached responses" and "intercepted by a service worker".

When I've handled these kinds of situations in the past, I've had to inject into the page's "world" to unregister its service worker before monkey-patching the appropriate objects/methods (e.g., the page's XMLHttpRequest object) as needed.

You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit


May 28, 2024, 1:56:08 AMMay 28
to Chromium Extensions, Cuyler Stuwe, Chromium Extensions, John Hansfeldt
If those cached requests aren't served by a service worker, it's a bug in the browser.

If a request is served by the site's service worker the "Size" column in devtools network log should say "Served from ServiceWorker", in which case it's because webRequest or declarativeNetRequest are designed to handle requests that go through the network process, while requests handled by the site's service worker are resolved internally by the site without going through the network process. Conceptually, this shouldn't prevent the possibility of exposing such requests to extensions and hopefully this will be implemented within our lifetime. Someone should open an issue in WECG.

You can also unregister the service worker in the background script via chrome.browsingData.
Reply all
Reply to author
0 new messages