首页 > 解决方案 > PuppeteerSharp:如何同时启用请求拦截和缓存?

问题描述

我想同时启用请求拦截和缓存。但是,在挖掘PuppeteerSharp源代码时,我发现似乎有故意的代码使这两个属性互斥。因此,我有两个问题:

  1. 为什么在 PuppeteerSharp 中缓存和请求拦截是互斥的?
  2. 是否可以覆盖它以便同时启用两者?如何?

以下是附加信息:

有关以下所有屏幕截图,请参阅https://github.com/hardkoded/puppeteer-sharp/blob/master/lib/PuppeteerSharp/NetworkManager.cs 。

该方法表示UpdateProtocolCacheDisabledAsync()当被调用时Fetch.enable调用,是DevTools内部用于请求拦截的方法。

在此处输入图像描述

_protocolRequestInterceptionEnabled当设置为truewhen_userRequestInterceptionEnabled也设置为 时,缓存实际上是禁用的true

在此处输入图像描述

在此处输入图像描述

标签: google-chrome-devtoolspuppeteerpuppeteer-sharp

解决方案


推荐阅读