$linuxjunkies
>

ccache

also: compiler cache

ccache is a compiler cache that speeds up compilation by storing intermediate build results and reusing them for identical source code, dramatically reducing rebuild times.

ccache (compiler cache) intercepts calls to C and C++ compilers and caches the object files produced. When you recompile the same source code with identical compiler flags, ccache serves the cached object file instead of recompiling, saving significant time.

It works transparently by wrapping your compiler commands. For example, instead of calling gcc directly, you call ccache gcc, and ccache handles caching automatically. This is especially valuable in large projects where you frequently rebuild after minor changes, or in CI/CD pipelines where the same code is compiled repeatedly.

Example:

ccache gcc -O2 -Wall myprogram.c -o myprogram
On the first run, this compiles normally. On subsequent identical compiles, ccache returns the cached object file in milliseconds instead of seconds or minutes.

ccache maintains a cache directory (typically ~/.cache/ccache) and uses file hashing to detect when source code or compiler flags change, invalidating stale cache entries automatically.

Related terms