`npm ci` takes 4 minutes on every run. Fix it.
BeginnerScenarioSpeed, Caching & Cost
Answer
Situation read → No dependency caching.
What I'd do →
- Configure built-in caching and a lean install:
- uses: actions/setup-node@v4 with: node-version-file: .nvmrc cache: npm - run: npm ci --prefer-offline --no-audit --no-fund - Confirm "Cache restored from key: node-cache-Linux-x64-npm-<hash>" in logs.
- Make sure a run on
mainpopulates the cache so PRs inherit it.
Why → The download cache cuts most of the time; npm ci keeps installs exact.
Interview tip → Explain branch scoping: PR caches do not help other PRs, main caches do.
More on Speed, Caching & Cost
Docker builds take 12 minutes even when only one line of code changed. Speed them up.IntermediateThe repo hits the 10 GB cache limit daily and hit rates are poor. What do you change?IntermediatemacOS jobs are 60% of your bill. What are your options?IntermediateA job sometimes hangs and burns 6 hours. How do you stop it happening again?BeginnerYour PR matrix is 3 OS times 4 versions (12 jobs). How do you cut cost without losing coverage?AdvancedTest suite takes 30 minutes on one runner. How do you parallelize it in Actions?Intermediate