Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

What is the difference between Gradle incremental builds (UP-TO-DATE) and the build cache (FROM-CACHE)?

An UP-TO-DATE task was skipped because its outputs from the last run in the same workspace are still in place and its inputs have not changed. A FROM-CACHE task was not run either, but its outputs were copied in from the build cache, which stores outputs under a key computed from the hash of all inputs and can restore them in any workspace, including on other machines through a remote cache. Only tasks marked cacheable take part in the build cache, which is enabled with --build-cache or org.gradle.caching=true, and the configuration cache is a separate feature that reuses the result of the configuration phase.

Why this question is asked

Both labels mean Gradle avoided work, so they are easy to confuse. The difference matters because they help in different situations: up-to-date checks save us when we rebuild the same checkout, while the build cache saves us after a clean, after switching branches, and across machines in CI. Interviewers ask this to check that we know which one we are relying on when we try to speed up a build. In this answer, we will recap what each one does, follow a task through both checks, see a short demonstration, look at what cacheable means, and finally separate both from the configuration cache.

1A Quick Recap of Avoiding Work

Every Gradle task has declared inputs, such as source files and compiler options, and outputs, such as a classes directory. Gradle computes a fingerprint of the inputs, a hash that changes whenever any input changes. Both features use this fingerprint; they differ in where the old outputs come from.

An incremental build compares the fingerprint with the one stored after the last execution of that task in this workspace, meaning this checkout on this machine. If they match and the outputs in the build directory are still intact, there is nothing to do, and the task is UP-TO-DATE. The build cache instead treats the fingerprint as a key, the cache key, and asks a store whether it already has outputs for that key from any earlier build. If it does, Gradle unpacks them into the build directory and reports FROM-CACHE.

2Following a Task Through Both Checks

When a task is about to run, Gradle tries the cheapest option first. Leaving existing files alone is cheaper than copying from a cache, and both are cheaper than running the task.

Step throughWhat Gradle tries before running a task
  1. Compute the cache keyhash of all input fingerprints and task code
  2. Outputs from the last run here still match?
    YesSkip: UP-TO-DATENoAsk the build cache
  3. Cacheable task and key found in a cache?local cache first, then remote
    YesUnpack outputs: FROM-CACHENoRun the task
  4. Run the taskEXECUTED
  5. Store outputs under the keyif the task is cacheable and push is allowed

5 steps in order. Play them, or step through them one at a time.

Notice that the order explains when each label appears. A second build of an unchanged checkout gives UP-TO-DATE, because the outputs are already there. A build after clean, or after checking out a branch where the task's inputs match something built before, gives FROM-CACHE, because the outputs are gone locally but the cache has them.

3Seeing the Difference on the Command Line

Here is the same project built four times. The build cache is turned on in gradle.properties.

Java
# gradle.properties
org.gradle.caching=true
./gradlew :core:compileJava # first build
> Task :core:compileJava (executed, outputs stored in the local cache)
./gradlew :core:compileJava # nothing changed
> Task :core:compileJava UP-TO-DATE (outputs still in build/)
./gradlew clean :core:compileJava
> Task :core:compileJava FROM-CACHE (build/ was deleted; outputs restored from the cache)
# edit a source file, build, then undo the edit and build again
> Task :core:compileJava (executed for the edited version)
> Task :core:compileJava FROM-CACHE (the original inputs are in the cache)

The last pair is the interesting one. Up-to-date checks only remember the most recent execution, so undoing an edit makes the task out of date again. The build cache remembers every set of inputs it has seen, within its size limit, so going back to an earlier state, such as switching back to the main branch, is restored from the cache. The local cache lives under the Gradle user home, by default in ~/.gradle/caches/build-cache-1, and a remote cache, typically an HTTP cache node, extends the same idea to every machine that shares it.

4Which Tasks Can Use the Build Cache

Up-to-date checks work for any task that declares inputs and outputs. The build cache is stricter: a task must be marked cacheable, because its outputs will be reused in a different place, and that is only safe if the outputs depend on nothing but the declared inputs. Built-in tasks such as JavaCompile, Test and Checkstyle are cacheable. Copy-like tasks such as Jar and Copy are deliberately not, because recreating a zip or copying files is about as fast as downloading the result.

For a custom task, we annotate the class with @CacheableTask and make sure file inputs use a relative path sensitivity, so a checkout in a different directory produces the same key. Without that, the task can still be UP-TO-DATE locally, but it will never be FROM-CACHE.

Java
@CacheableTask
abstract class GenerateSchema : DefaultTask() {
@get:InputFiles @get:PathSensitive(PathSensitivity.RELATIVE)
abstract val sources: ConfigurableFileCollection
@get:OutputDirectory abstract val outputDir: DirectoryProperty
@TaskAction fun generate() { /* ... */ }
}

5The Configuration Cache Is a Different Thing

Before any task runs, Gradle has to run the configuration phase: evaluate the build scripts, apply plugins and build the graph of tasks to execute. In a large build this alone can take 10 to 30 seconds. The configuration cache stores the result of that phase, the task graph with its configured values, and reuses it when the scripts and the values they read have not changed. It is enabled with --configuration-cache or org.gradle.configuration-cache=true.

So the three features work at different levels. The configuration cache skips configuring; up-to-date checks and the build cache skip executing tasks. They combine well: with all three, an unchanged build can start executing almost immediately and then find every task up to date or in the cache.

Three ways Gradle avoids work
FeatureWhat it reusesWhere it worksTurn it on
Up-to-date checksTask outputs from the last runSame workspace onlyAlways on
Build cacheTask outputs keyed by input hashAny workspace; remote cache: any machine--build-cache or org.gradle.caching=true
Configuration cacheThe configured task graphSame build, same inputs--configuration-cache

6Follow-up questions

Why would a task be UP-TO-DATE locally but always miss the remote cache?

Up-to-date checks compare against the same workspace, so absolute paths, the local JDK and the local line endings never vary. The remote cache compares across machines, where any of those can differ and produce a different key. Absolute path sensitivity, different JDK versions and volatile inputs are the usual causes, and the caching debug flag shows which input hash differs.

Is it safe to share a remote cache between CI and developers?

Yes, if tasks declare their inputs correctly, because a cache key covers everything that affects the outputs. The common setup is that CI builds push to the remote cache and developer machines only read from it, so an unusual local environment cannot put surprising entries into the shared cache.

Does FROM-CACHE mean tests did not run?

Yes. If the Test task's inputs, including the test classes, the runtime classpath and the JVM settings, match a cached run, Gradle restores the test reports and results instead of running the tests. That is correct as long as the tests depend only on declared inputs; tests that call external systems may need extra inputs or must not be cached.

7Conclusion

In this answer, we saw that UP-TO-DATE means the outputs of the last run in the same workspace are still valid, while FROM-CACHE means outputs were restored from a build cache keyed by the hash of the inputs, which works after clean, across branches and, with a remote cache, across machines. Only cacheable tasks use the build cache, enabled with --build-cache or org.gradle.caching=true, and custom tasks need @CacheableTask and relative path sensitivity. The configuration cache is separate: it reuses the configured task graph rather than task outputs.

What to say in the interviewAbout 80 seconds aloud

Open with

Both mean Gradle did not run the task, but the outputs come from different places. UP-TO-DATE is the incremental build check. Gradle fingerprints the task's inputs and compares them with what it recorded after the last execution in this same workspace, and if they match and the files in the build directory are intact, it leaves them alone.

Then, if they want more

It only remembers the latest run, and it only works in that checkout. FROM-CACHE means the build cache was used. The fingerprint of all inputs becomes a cache key, and Gradle looks the key up in the local cache under the Gradle user home or in a remote cache shared by CI and developers.

If it finds outputs, it unpacks them. That works after a clean, after switching branches back and forth, and on a different machine. Only tasks marked cacheable take part, like JavaCompile and Test; custom tasks need the CacheableTask annotation and relative path sensitivity, otherwise absolute paths break the keys across machines.

The build cache is turned on with --build-cache or org.gradle.caching=true in gradle.properties, whereas up-to-date checks are always on. And I would keep both apart from the configuration cache, which caches the result of the configuration phase, the task graph, not the outputs of tasks.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Gradle user manual
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What is the difference between Gradle incremental builds (UP-TO-DATE) and the build...": https://scrivio-interview-library.netlify.app/java/gradle/d872c22fd4/