Interview Prep/GitHub Actions/Speed, Caching & Cost

`npm ci` takes 4 minutes on every run. Fix it.

BeginnerScenarioSpeed, Caching & Cost
Answer

Situation read → No dependency caching.

What I'd do →

  1. 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
    
  2. Confirm "Cache restored from key: node-cache-Linux-x64-npm-<hash>" in logs.
  3. Make sure a run on main populates 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.

All GitHub Actions questions Roadmap: GitHub Actions

More on Speed, Caching & Cost