DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
browser automation

How to Configure Caching for Browser Automation

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Browser automation has three different kinds of “cache,” and configuring one does not configure the others:

  • Installation caches retain Playwright browsers, Puppeteer browsers, or Selenium Manager drivers between jobs.
  • HTTP caches retain web responses inside a browser context and affect page behavior.
  • Storage state preserves cookies, local storage, and optionally IndexedDB so a later context can reuse a session.

Start by identifying which result you need. For faster CI setup, persist the framework’s download directory. For a realistic browser-cache test, avoid request interception that disables caching. For a reusable login, export storage state and protect the resulting file as a credential.

Choose the cache you actually need

Mechanism Retains Scope and lifetime Typical use
Playwright/Puppeteer/Selenium installation cache Browser or driver binaries Filesystem directory shared by jobs or machines Prevent downloads during every CI run
Browser HTTP cache HTTP responses and related browser cache data Browser profile or context, subject to browser and framework behavior Test repeat visits, cache headers, and offline-like behavior
Playwright storage state Cookies, local storage, and optionally IndexedDB Saved state file loaded into a new context Reuse authentication or application state

These layers are independent. A cached Chromium binary does not make a page load from HTTP cache, and a saved cookie file does not contain JavaScript bundles or images.

Cache Playwright browsers in CI

Playwright’s documented defaults are %USERPROFILE%AppDataLocalms-playwright on Windows, ~/Library/Caches/ms-playwright on macOS, and ~/.cache/ms-playwright on Linux. Set PLAYWRIGHT_BROWSERS_PATH when you want a stable, explicitly persisted directory. The directory must be available to the CI job before tests start.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Seagate BarraCuda 4TB Internal Hard Drive HDD – 3.5 Inch Sata 6 Gb/s 5400 RPM 256MB Cache For Computer Desktop PC – Frustration Free Packaging ST4000DMZ04/DM004
  • Store more, compute faster, and do it confidently with the proven reliability of BarraCuda internal hard drives
  • Build a powerhouse gaming computer or desktop setup with a variety of capacities and form factors
  • The go to SATA hard drive solution for nearly every PC application from music to video to photo editing to PC gaming
  • Confidently rely on internal hard drive technology backed by 20 years of innovation; Max sustained transfer rate OD(MB/s): 190 MB/s
  • Migrate and clone data from old drives with ease using our free Seagate DiscWizard software tool

Set a controlled directory

# Linux/macOS shell
export PLAYWRIGHT_BROWSERS_PATH="$HOME/.cache/playwright-browsers"
 npx playwright install chromium
 npx playwright test

# Windows PowerShell
$env:PLAYWRIGHT_BROWSERS_PATH = "$env:USERPROFILE.cacheplaywright-browsers"
npx playwright install chromium
npx playwright test

Configure your CI provider’s cache action or cache service to save and restore that directory. Use a key that includes the operating system, architecture, and the Playwright package or lockfile version; otherwise a job can restore binaries that no longer match the framework release. On a cache miss, run the install command and let the job repopulate the directory. Do not assume a particular CI vendor or a universal cache-key syntax.

Validate the restored cache

  1. Print the effective PLAYWRIGHT_BROWSERS_PATH in the job log without exposing secrets.
  2. Restore the directory before npx playwright test.
  3. Run the same Playwright version used by the project’s lockfile.
  4. If the browser executable is missing or incompatible, delete the restored directory, run npx playwright install, and save a new versioned entry.

The installation cache only removes setup downloads. It does not guarantee that a site’s responses are cached.

Configure Puppeteer’s browser-download cache

Puppeteer’s official troubleshooting documentation says that, starting with v19.0.0, downloaded browsers go to ~/.cache/puppeteer by default. Check your installed version before applying a path assumption.

Environment-variable method

# Linux/macOS
export PUPPETEER_CACHE_DIR="$HOME/.cache/puppeteer-ci"
npm ci
npx puppeteer browsers install

Persist PUPPETEER_CACHE_DIR with your CI cache service. The cache key should include the operating system and the Puppeteer version (or lockfile hash).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configuration-file method

// .puppeteerrc.js or puppeteer.config.js
module.exports = {
  cacheDirectory: process.env.PUPPETEER_CACHE_DIR || '/tmp/puppeteer-cache'
};

Puppeteer’s documentation notes that Puppeteer must be reinstalled for a change to this configuration to take effect. Verify the resulting directory after installation rather than assuming an existing cache moved automatically.

Configure Selenium Manager’s cache

Selenium Manager stores downloaded browser and driver assets in ~/.cache/selenium by default. Its cache also contains se-config.toml and se-metadata.json; the metadata records discovered versions and a TTL. Cache that directory only when the operating system, architecture, and Selenium setup are compatible.

Rank #2
Seagate BarraCuda 2TB Internal Hard Drive HDD – 3.5 Inch SATA 6Gb/s 7200 RPM 256MB Cache – Frustration Free Packaging (ST2000DM008/ST2000DMZ08)
  • Migrate and clone data from old drives with ease using our free Seagate DiscWizard software tool
  • Store more, compute faster, and do it confidently with the proven reliability of BarraCuda internal hard drives
  • Build a powerhouse gaming computer or desktop setup with a variety of capacities and form factors
  • The go to SATA hard drive solution for nearly every PC application—from music to video to photo editing to PC gaming
  • Confidently rely on internal hard drive technology backed by 20 years of innovation

A restored Selenium Manager directory can avoid repeated downloads, but its metadata is not proof that every driver-discovery scenario works offline. Keep Selenium, browser, and driver versions aligned, and allow Selenium Manager to refresh assets when metadata says they are stale. Do not apply one assumed TTL to every Selenium installation.

Test the browser’s HTTP cache correctly

HTTP-cache testing asks a different question: will the browser reuse a response rather than request it again? Use a normal browser context and observe requests, response headers, and server logs. Keep the test’s cache policy explicit: a fresh context, a persistent profile, and a context restored from disk have different histories.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Playwright’s routing caveat

Playwright’s BrowserContext documentation states: “Enabling routing disables http cache.” A route used for mocking, blocking, or rewriting requests can therefore change the very behavior under test. If cache fidelity matters, do not enable routing in that test. If interception is essential, treat the result as an intercepted-request test rather than an authentic browser-cache test. See the Playwright BrowserContext documentation.

A minimal cache-observation example

import { chromium } from 'playwright';

const browser = await chromium.launch();
const context = await browser.newContext(); // no routing: HTTP cache can operate normally
const page = await context.newPage();
page.on('request', request => {
  if (request.resourceType() === 'document') console.log('request', request.url());
});
await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.reload({ waitUntil: 'networkidle' });
await browser.close();

This example does not promise that every resource will be served from cache: server headers, browser policy, revalidation, cache size, and the site itself decide that. To test a specific resource, inspect its response status and headers and compare a first navigation with a repeat navigation under the same context.

Reuse cookies and local storage with Playwright storage state

Playwright’s browserContext.storageState() exports cookies and local storage. It can include IndexedDB when requested, and a later context can be initialized from the saved state. This is session reuse, not response caching. The Playwright API-testing guide demonstrates saving state and creating another context from it; the Browser documentation covers browser and context lifecycle APIs.

Save state after authentication

import { chromium } from 'playwright';

const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://example.com/login');
// Complete the site-specific login flow here.
await context.storageState({ path: 'playwright/.auth/user.json', indexedDB: true });
await browser.close();

Load it in a later test

import { chromium } from 'playwright';

const browser = await chromium.launch();
const context = await browser.newContext({
  storageState: 'playwright/.auth/user.json'
});
const page = await context.newPage();
await page.goto('https://example.com/account');
await browser.close();
  • Keep the state file outside public repositories and CI artifacts.
  • Restrict filesystem permissions and secret-scanning exposure.
  • Regenerate it when credentials expire or the application changes its session format.
  • Use separate state files for separate test identities.

A state file may carry authentication cookies, refresh tokens, or other sensitive values. Treat it like a password.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Western Digital Blue WD5000AZLX 500GB 7200 RPM 32MB Cache SATA 6.0Gb/s 3.5" Internal Hard Drive Bare Drive
  • High Capacity: 500GB hard drive provides ample storage space for your computer needs.
  • Fast Read Speed: 6.0Gb/s read speed allows for quick access to files and programs.
  • Reliable Performance: 7200RPM rotational speed ensures consistent performance and longevity.
  • Easy Installation: 3.5-inch form factor fits easily into desktop computers.
  • Durable Design: Withstands drops and vibrations for reliable operation.

CI design: keys, invalidation, and portability

Build cache keys from compatibility inputs

Include framework version, lockfile hash, operating system, CPU architecture, and (where relevant) browser channel in the key. A key that contains only “playwright” or “selenium” can restore an incompatible binary.

Separate installation and test-data caches

Keep browser binaries, HTTP profiles, and authentication state in different cache entries. Installation caches are usually shareable among jobs with the same compatibility inputs; authentication state should be narrowly scoped. Never upload a logged-in profile as a broad dependency cache.

Plan invalidation

Invalidate after framework upgrades, browser-channel changes, operating-system image changes, or unexplained executable errors. For HTTP-cache tests, explicitly create a fresh context when testing a cold cache and reuse the same context or profile when testing a warm cache.

Performance, reliability, and cost considerations

  • Performance: Installation caching removes browser and driver downloads, but the actual time saved depends on artifact size, network speed, compression, and cache-service latency. The official documentation cited here provides no universal percentage improvement.
  • Reliability: A cache is an optimization, not a required source of truth. Keep a fallback install path for cache misses and corrupt archives.
  • Disk usage: Multiple browser channels, architectures, and framework versions can consume substantial space. Prune entries according to your CI retention policy.
  • Fidelity: Request routing can disable Playwright HTTP cache; storage-state reuse changes authentication state. Record those choices in the test’s setup.
  • Security: Binary caches need integrity and access controls; state caches need secret-level protection.

Common failures and fixes

“Executable doesn’t exist” after restoring a cache

Cause: The directory was restored under a different path, the cache was keyed to another framework version, or installation never ran after a miss.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix: Print the path, delete the incompatible entry, run the framework’s install command, and save a cache keyed by the lockfile and platform.

Puppeteer keeps downloading browsers

Cause: PUPPETEER_CACHE_DIR differs between install and test steps, or the configured directory was changed without reinstalling Puppeteer.

Rank #4
Seagate BarraCuda Pro 500GB Internal Hard Drive Performance HDD – 2.5 Inch SATA 6Gb/s 7200 RPM 128MB Cache for Computer Desktop PC Laptop, Data Recovery – Frustration Free Packaging (ST500LM034)
  • Store more, compute faster, and do it confidently with the proven reliability of BarraCuda Pro internal hard drives
  • Tackle large projects or build a gaming computer with 500GB of capacity
  • Jump into PC gaming or edit music, video, and photos effortlessly with 7200 RPM speeds and optimized read/write caching technology
  • Confidently rely on internal hard drive technology backed by 20 years of innovation
  • Enjoy long-term peace of mind with the included five-year limited warranty and two-year Rescue Data Recovery Services

Fix: Export the same variable in both steps, verify the directory exists, and reinstall after changing cacheDirectory.

Selenium Manager ignores a restored asset

Cause: The cached metadata marks it stale, or the browser and driver do not match the current environment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix: Allow discovery and refresh, inspect se-metadata.json, and use a platform- and version-specific cache.

Requests are not coming from HTTP cache

Cause: Playwright routing is enabled, the context is new, or the server requires revalidation.

Fix: Remove routing for the cache-fidelity test, reuse the intended context, and inspect response headers. Remember that Playwright documents routing as disabling HTTP cache.

A restored login is rejected

Cause: Expired cookies, missing IndexedDB, a changed origin, or a state file from another account.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Hiseeu 3TB Internal Hard Drive HDD SATA 6Gb/s 64MB Cache 3.5 Inch
  • 3TB Capacity, IntelliPower (5400RPM~7200RPM) Rotation Speed, 64MB Cache
  • 3.5" Internal Hard Drive, SATA III 6.0Gb/s, Bulk single pack, Not include cable, screws or accessories.
  • The Internal HDD is designed for 24/7 Operation, Lower Power consumption & Heavy Duty, Cool Temperature
  • The surveillance hard drive works for Servers, PC, Mac, RAID, NAS, and compatible with the Hiseeu asin: B08LQJJPFC、B0819ZHF5C、B0B9G7TZFS、B07LGLVS4M、B07FR1LDSM
  • Quality Guaranteed. 1 year warranty for free replacement

Fix: Re-authenticate, export with indexedDB: true when required, and keep state files separated by account and environment.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is a dependable screenshot rather than testing cache semantics, ScreenshotNeo returns a PNG, JPEG, WebP, or PDF from one request. Its cleaner accepts cookie or consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Use the documented options for full-page or element capture, device and retina settings, waits, custom CSS or JavaScript, headers and cookies, blocking rules, caching with a chosen TTL, signed links, asynchronous jobs, bulk capture, and PDF output. These options control capture behavior; they do not replace a browser-cache test.

See the ScreenshotNeo API documentation. cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Should I cache browser binaries in a container image instead of CI storage?

Use an image when the browser version is intentionally fixed and rebuilding the image is acceptable; use CI caching when you need independent invalidation and smaller image layers. Keep the same version and platform checks either way.

Can one cache be shared by Playwright, Puppeteer, and Selenium?

No. Their managed directories, metadata, download formats, and compatibility rules differ. Maintain separate caches unless you have explicitly verified a supported integration.

How can I prove a test used a warm HTTP cache?

Use a repeat navigation in the same context, capture request and response details, and correlate them with server logs or browser instrumentation. A successful second navigation alone does not prove every resource was served without revalidation.

Quick Recap

Bestseller No. 2
Bestseller No. 3
Western Digital Blue WD5000AZLX 500GB 7200 RPM 32MB Cache SATA 6.0Gb/s 3.5' Internal Hard Drive Bare Drive
Western Digital Blue WD5000AZLX 500GB 7200 RPM 32MB Cache SATA 6.0Gb/s 3.5" Internal Hard Drive Bare Drive
High Capacity: 500GB hard drive provides ample storage space for your computer needs.; Fast Read Speed: 6.0Gb/s read speed allows for quick access to files and programs.
$68.88
Bestseller No. 4
Seagate BarraCuda Pro 500GB Internal Hard Drive Performance HDD – 2.5 Inch SATA 6Gb/s 7200 RPM 128MB Cache for Computer Desktop PC Laptop, Data Recovery – Frustration Free Packaging (ST500LM034)
Seagate BarraCuda Pro 500GB Internal Hard Drive Performance HDD – 2.5 Inch SATA 6Gb/s 7200 RPM 128MB Cache for Computer Desktop PC Laptop, Data Recovery – Frustration Free Packaging (ST500LM034)
Tackle large projects or build a gaming computer with 500GB of capacity; Confidently rely on internal hard drive technology backed by 20 years of innovation
$69.99
Bestseller No. 5
Hiseeu 3TB Internal Hard Drive HDD SATA 6Gb/s 64MB Cache 3.5 Inch
Hiseeu 3TB Internal Hard Drive HDD SATA 6Gb/s 64MB Cache 3.5 Inch
3TB Capacity, IntelliPower (5400RPM~7200RPM) Rotation Speed, 64MB Cache; Quality Guaranteed. 1 year warranty for free replacement
$139.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.