For AI agents: the complete documentation index is available at https://docs.hod.sh/llms.txt, the full documentation bundle is available at https://docs.hod.sh/llms-full.txt, and this page is available as Markdown at https://docs.hod.sh/pipelines/caching.md.

Caching

Hod has two caches. The step cache skips work: a step whose inputs didn't change isn't run, and its results are restored. The dependency cache only makes a job faster: it keeps directories such as a package manager's downloads between runs.

The step cache

cache.inputs on a step lists the files and directories its result depends on. When nothing the step depends on changed (those files, its script, its variables, the job's image, and the files it got from the jobs it needs), the step is skipped and its files and outputs are restored.

version: 0
on: [push]
jobs:
  build:
    image: node:22
    steps:
      - run: npm ci && npm run build
        cache:
          inputs: [package-lock.json, src/]
        files: [dist/]

Patterns use *, which stays within a directory, and **, which crosses them. A directory name covers everything under it, and ./src is the same as src. Use it on steps whose result depends only on those inputs.

The dependency cache

cache: on a job restores directories before the first step that runs, and saves them when the job succeeds. Each entry is a preset name or a map with paths (directories to keep) and key_files (files whose contents make the key, such as lock files).

version: 0
on: [push]
jobs:
  build:
    image: maven:3.9-eclipse-temurin-21
    cache:
      - paths: [$HOME/.m2/repository]
        key_files: [pom.xml]
    steps:
      - run: mvn -B package

The presets are npm, pip, go and rust (cargo's registry and git checkouts): cache: [npm]. hod plan --expand shows what a preset becomes. Paths are expanded in the job's environment, so $HOME is the container's, ~/ is $HOME/, and a relative path is inside the workspace. Without an entry for the key, the newest entry of the same paths, job and image is restored, and a new one is saved when the job succeeds.

What is never cached

Tag runs, and jobs that hold a secret, an identity or push:, use neither cache: they build from scratch, so nothing another job wrote reaches what they release. A step with push:, secrets: or identity: can't have cache:.

fresh: true does the same for a job that holds none of those but whose output ships, such as a build whose files a publishing job needs:. A fresh job restores and saves no cache, a component's included, and cache: on it, or on one of its steps, doesn't compile.

version: 0
on:
  push:
    branches: [main]
  pull_request: {}
jobs:
  test:                  # runs on every change: the cache speeds it up
    image: node:24
    cache: [npm]
    steps:
      - run: npm ci && npm test
  build-release:         # what ships: from scratch
    if: event.is_default_branch
    needs: [test]
    image: node:24
    fresh: true
    steps:
      - run: npm ci && npm run build
        files: [dist/]
  deploy:                # holds a secret: no cache either way
    needs: [build-release]
    image: node:24
    steps:
      - run: npx wrangler deploy
        secrets: [CLOUDFLARE_API_TOKEN]