Skip to content

Commit 80ed90b

Browse files
committed
Clean browser state between fetches
1 parent 9402653 commit 80ed90b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/archivist/fetcher/fullDomFetcher.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ export default async function fetch(url, cssSelectors, config) {
2020
await page.setDefaultNavigationTimeout(config.navigationTimeout);
2121
await page.setExtraHTTPHeaders({ 'Accept-Language': config.language });
2222

23+
await page.setCacheEnabled(false); // Disable cache to ensure fresh content on each fetch and prevent stale data from previous requests
24+
const client = await page.target().createCDPSession();
25+
26+
await client.send('Network.clearBrowserCookies'); // Clear cookies to ensure clean state between fetches and prevent session persistence across different URLs
27+
2328
response = await page.goto(url, { waitUntil: 'load' }); // Using `load` instead of `networkidle0` as it's more reliable and faster. The 'load' event fires when the page and all its resources (stylesheets, scripts, images) have finished loading. `networkidle0` can be problematic as it waits for 500ms of network inactivity, which may never occur on dynamic pages and then triggers a navigation timeout.
2429

2530
if (!response) {

0 commit comments

Comments
 (0)