From b9ab6fe4bb8b526268e05609a3a2b171579e570a Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 24 Oct 2017 15:14:25 -0700 Subject: [PATCH] fix(interception): Disable newtork caching when intercepting (#1154) Request interception might not work properly if caching is enabled. --- docs/api.md | 2 ++ lib/NetworkManager.js | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/api.md b/docs/api.md index 18d3f9e2..f898a689 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1007,6 +1007,8 @@ puppeteer.launch().then(async browser => { > **NOTE** Request interception doesn't work with data URLs. Calling `abort`, > `continue` or `respond` on requests for data URLs is a noop. +> **NOTE** Enabling request interception disables page caching. + #### page.setUserAgent(userAgent) - `userAgent` <[string]> Specific user agent to use in this page - returns: <[Promise]> Promise which resolves when the user agent is set. diff --git a/lib/NetworkManager.js b/lib/NetworkManager.js index b0919532..608f1e8f 100644 --- a/lib/NetworkManager.js +++ b/lib/NetworkManager.js @@ -117,7 +117,10 @@ class NetworkManager extends EventEmitter { return; this._protocolRequestInterceptionEnabled = enabled; const patterns = enabled ? [{urlPattern: '*'}] : []; - await this._client.send('Network.setRequestInterception', {patterns}); + await Promise.all([ + this._client.send('Network.setCacheDisabled', {cacheDisabled: enabled}), + this._client.send('Network.setRequestInterception', {patterns}) + ]); } /**