My software includes a third-party library which rarely changes and takes 8 minutes to build, so I figured I can speed up the pipeline by caching the build output. I have the following github workflow cache action:
- name: Cache third-party libraries
id: cache-libs
uses: actions/cache@v3
with:
path: Path\to\libs
key: "test-key"
On the first build, the "Cache third-party libraries" step fails to find the cache, which is expected:
Run actions/cache@v3
Cache not found for input keys: test-key
After the build, I see that the cache is created in "Post Cache third-party libraries" step:
6s
Post job cleanup.
"C:\Program Files\Git\usr\bin\tar.exe" --posix -cf cache.tzst --exclude cache.tzst -P -C C:/GitHub/RUNNER-1/_work/project/project --files-from manifest.txt --force-local --use-compress-program "zstd -T0"
Cache Size: ~13 MB (13645556 B)
Cache saved successfully
Cache saved with key: test-key
I can see the cache entry when I visit my_repo/actions/caches
.
However, when I restart the workflow, restoring the cache fails:
Run actions/cache@v3
Warning: Failed to restore: Content-Length not found on blob response
Cache not found for input keys: test-key
What does this error mean exactly, and is there a way to fix it?
EDIT: I have also tried to trigger the save action directly after the build (as described here), but the behavior is the same: the save step works, but on a re-run the cache fetch fails with "Content-Length not found on blob response" message.
The reason for "Content-Length not found on blob response" is that caches are disabled on our GitHub Enterprise Server, as I just found out. The confusing part is that the error only appears when restoring a cache, and now when it is created.
For now, I just installed ccache
alongside the compiler, which helps to speed up repetitive builds of the same source files.