Skip to content
ENExplore Calculators

Layer Cache Efficiency Calculator

Work out layer cache efficiency instantly with clear inputs, formula shown and shareable results.

About Layer Cache Efficiency Calculator

Docker invalidates a layer and everything after it when its inputs change, so layer ordering determines cache efficiency. Copying application source before installing dependencies invalidates the expensive dependency layer on every code change; copying only the manifest first, installing, then copying source keeps that layer cached and cuts the rebuilt layer count dramatically.

Formula

Layer cache

cached share = (total - invalidated) / total; incremental build = invalidated x per-layer time; saving = (total - invalidated) x per-layer time x builds

Worked example

With the default values below, Layer Cache Efficiency Calculator returns Layers reused from cache of 71.4%. Change any input above and every figure here is recalculated in your browser.

Inputs used

Layers in the imageaccepts 1–128
14
Layers rebuilt on a typical changeminimum 0
4
Average build time per layerminimum 0.1 s
22 s
Builds per dayminimum 1
120

Results

Layers reused from cache
71.4%
Incremental build time
88 s
Cold build time
308 s
Build hours saved per day
7.33 h

Step by step

  1. 1Values used
  2. 2Layer cache
  3. 3Layers reused from cache= 71.4
  4. 4Incremental build time= 88 s
  5. 5Cold build time= 308 s
  6. 6Build hours saved per day= 7.33 h

Assumptions and limits

  • The result is derived only from the 4 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to 2 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

Why does one early change rebuild everything?

Cache invalidation cascades. Any layer after the changed one must be rebuilt because its base has changed, regardless of whether its own inputs did.

How should a Dockerfile be ordered?

Least frequently changing first: base image, system packages, dependency manifests, dependency install, then application source last.

Layer Cache Efficiency Calculator | Calcrivo