
Playwright Ci Caching
- 340 installs
- 1.1k repo stars
- Updated July 3, 2026
- aaronontheweb/dotnet-skills
playwright-ci-caching is a CI/CD skill that caches Playwright browser binaries in GitHub Actions and Azure DevOps pipelines to avoid roughly 400MB downloads and 1-2 minute overhead on every .NET web app build.
About
playwright-ci-caching is an agent skill from aaronontheweb/dotnet-skills for speeding up Playwright end-to-end test pipelines. Playwright browsers weigh roughly 400MB and download on every CI run by default, adding 1-2 minutes of overhead and wasting bandwidth. The skill shows how to cache browser binaries in GitHub Actions and Azure DevOps with automatic invalidation when the Playwright version changes. .NET teams reach for playwright-ci-caching when E2E suites are correct but PR builds feel slow due to repeated browser installs. The result is reliable faster feedback on every pull request without skipping browser updates when versions bump.
- Cache Playwright browsers in CI
- Faster E2E pipeline runs
- Reduce flaky download steps
- PR feedback acceleration
- .NET web test integration
Playwright Ci Caching by the numbers
- 340 all-time installs (skills.sh)
- Ranked #671 of 2,153 Testing & QA skills by installs in the Skillselion catalog
- Data as of Aug 3, 2026 (Skillselion catalog sync)
npx skills add https://github.com/aaronontheweb/dotnet-skills --skill playwright-ci-cachingAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 340 |
|---|---|
| repo stars | ★ 1.1k |
| Last updated | July 3, 2026 |
| Repository | aaronontheweb/dotnet-skills ↗ |
How do you cache Playwright browsers in CI pipelines?
Speed up Playwright end-to-end suites in CI by caching browsers, dependencies, and artifacts so .NET web apps get reliable faster feedback on every pull request.
Who is it for?
.NET developers running Playwright E2E tests in GitHub Actions or Azure DevOps who lose 1-2 minutes per build to browser downloads.
Skip if: Projects without Playwright E2E tests or teams using CI platforms the skill does not cover when no browser caching applies.
When should I use this skill?
CI builds are slow because Playwright downloads ~400MB browsers every run and the pipeline uses GitHub Actions or Azure DevOps.
What you get
CI cache configuration, Playwright browser cache keys, and pipeline YAML with version-aware cache invalidation.
- ci cache yaml
- playwright version-aware cache keys
By the numbers
- Playwright browser binaries are roughly 400MB per download
- Default uncached CI runs add 1-2 minutes of browser install overhead
Files
Caching Playwright Browsers in CI/CD
When to Use This Skill
Use this skill when:
- Setting up CI/CD for a project with Playwright E2E tests
- Build times are slow due to browser downloads (~400MB, 1-2 minutes)
- You want automatic cache invalidation when Playwright version changes
- Using GitHub Actions or Azure DevOps pipelines
The Problem
Playwright browsers (~400MB) must be downloaded on every CI run by default. This:
- Adds 1-2 minutes to every build
- Wastes bandwidth
- Can fail on transient network issues
- Slows down PR feedback loops
Core Pattern
1. Extract Playwright version from Directory.Packages.props (CPM) to use as cache key 2. Cache browser binaries using platform-appropriate paths 3. Conditional install - only download on cache miss 4. Automatic cache bust - key includes version, so package upgrades invalidate cache
Cache Paths by OS
| OS | Path |
|---|---|
| Linux | ~/.cache/ms-playwright |
| macOS | ~/Library/Caches/ms-playwright |
| Windows | %USERPROFILE%\AppData\Local\ms-playwright |
GitHub Actions
- name: Get Playwright Version
shell: pwsh
run: |
$propsPath = "Directory.Packages.props"
[xml]$props = Get-Content $propsPath
$version = $props.Project.ItemGroup.PackageVersion |
Where-Object { $_.Include -eq "Microsoft.Playwright" } |
Select-Object -ExpandProperty Version
echo "PlaywrightVersion=$version" >> $env:GITHUB_ENV
- name: Cache Playwright Browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PlaywrightVersion }}
- name: Install Playwright Browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
shell: pwsh
run: ./build/playwright.ps1 install --with-depsMulti-OS GitHub Actions
For workflows that run on multiple operating systems:
- name: Cache Playwright Browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: |
~/.cache/ms-playwright
~/Library/Caches/ms-playwright
~/AppData/Local/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PlaywrightVersion }}Azure DevOps
- task: PowerShell@2
displayName: 'Get Playwright Version'
inputs:
targetType: 'inline'
script: |
[xml]$props = Get-Content "Directory.Packages.props"
$version = $props.Project.ItemGroup.PackageVersion |
Where-Object { $_.Include -eq "Microsoft.Playwright" } |
Select-Object -ExpandProperty Version
Write-Host "##vso[task.setvariable variable=PlaywrightVersion]$version"
- task: Cache@2
displayName: 'Cache Playwright Browsers'
inputs:
key: 'playwright | "$(Agent.OS)" | $(PlaywrightVersion)'
path: '$(HOME)/.cache/ms-playwright'
cacheHitVar: 'PlaywrightCacheHit'
- task: PowerShell@2
displayName: 'Install Playwright Browsers'
condition: ne(variables['PlaywrightCacheHit'], 'true')
inputs:
filePath: 'build/playwright.ps1'
arguments: 'install --with-deps'Helper Script: playwright.ps1
Create a build/playwright.ps1 script that discovers and runs the Playwright CLI. This abstracts away the Playwright CLI location which varies by project structure.
# build/playwright.ps1
# Discovers Microsoft.Playwright.dll and runs the bundled Playwright CLI
param(
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$Arguments
)
# Find the Playwright DLL (after dotnet build/restore)
$playwrightDll = Get-ChildItem -Path . -Recurse -Filter "Microsoft.Playwright.dll" -ErrorAction SilentlyContinue |
Select-Object -First 1
if (-not $playwrightDll) {
Write-Error "Microsoft.Playwright.dll not found. Run 'dotnet build' first."
exit 1
}
$playwrightDir = $playwrightDll.DirectoryName
# Find the playwright CLI (path varies by OS and node version)
$playwrightCmd = Get-ChildItem -Path "$playwrightDir/.playwright/node" -Recurse -Filter "playwright.cmd" -ErrorAction SilentlyContinue |
Select-Object -First 1
if (-not $playwrightCmd) {
# Try Unix executable
$playwrightCmd = Get-ChildItem -Path "$playwrightDir/.playwright/node" -Recurse -Filter "playwright" -ErrorAction SilentlyContinue |
Where-Object { $_.Name -eq "playwright" } |
Select-Object -First 1
}
if (-not $playwrightCmd) {
Write-Error "Playwright CLI not found in $playwrightDir/.playwright/node"
exit 1
}
Write-Host "Using Playwright CLI: $($playwrightCmd.FullName)"
& $playwrightCmd.FullName @ArgumentsUsage:
# Install browsers
./build/playwright.ps1 install --with-deps
# Install specific browser
./build/playwright.ps1 install chromium
# Show installed browsers
./build/playwright.ps1 install --dry-runPrerequisites
This pattern assumes:
1. Central Package Management (CPM) with Directory.Packages.props:
<Project>
<ItemGroup>
<PackageVersion Include="Microsoft.Playwright" Version="1.40.0" />
</ItemGroup>
</Project>2. Project has been built before running playwright.ps1 (so DLLs exist)
3. PowerShell available on CI agents (pre-installed on GitHub Actions and Azure DevOps)
Why Version-Based Cache Keys Matter
Using the Playwright version in the cache key ensures:
- Automatic invalidation when you upgrade Playwright
- No stale browser binaries that don't match the SDK version
- No manual cache clearing needed after version bumps
If you hardcode the cache key (e.g., playwright-browsers-v1), you'll need to manually bump it every time you upgrade Playwright, or you'll get cryptic version mismatch errors.
Troubleshooting
Cache not being used
1. Verify the version extraction step outputs the correct version 2. Check that the cache path matches your OS 3. Ensure Directory.Packages.props exists and has the Playwright package
"Browser not found" after cache hit
The cached browsers don't match the Playwright SDK version. This happens when:
- The cache key doesn't include the version
- The version extraction failed silently
Fix: Ensure the Playwright version is in the cache key.
playwright.ps1 can't find the DLL
Run dotnet build or dotnet restore before running the script. The Playwright DLL only exists after NuGet restore.
References
This pattern is battle-tested in production projects:
Related Skills
dotnet-skills:playwright-blazor- Writing Playwright tests for Blazor applicationsdotnet-skills:project-structure- Central Package Management setup
Related skills
How it compares
Use playwright-ci-caching for pipeline browser caching; use Playwright test-authoring skills when writing or debugging E2E specs themselves.
FAQ
How much time does Playwright CI caching save?
playwright-ci-caching addresses Playwright browser downloads of roughly 400MB that add 1-2 minutes to every CI run by default. Caching binaries in GitHub Actions or Azure DevOps removes that repeated install overhead.
Which CI platforms does playwright-ci-caching support?
playwright-ci-caching covers GitHub Actions and Azure DevOps pipelines for .NET projects with Playwright E2E tests. It includes cache key patterns that invalidate when the Playwright version changes.