Actions/cache-v2 does not reliably save vcpkg binary caches

Recent versions of vcpkg create binary cache files whenever they build a package, for later reuse. They are stored in $HOME\.cache\vcpkg\archives.

Starting package 4/114: mpfr:x64-linux
Building package mpfr[core]:x64-linux...
-- Downloading; -> mpfr-4.1.0.tar.xz...
-- Extracting source /usr/local/share/vcpkg/downloads/mpfr-4.1.0.tar.xz
-- Applying patch gmpd.patch
-- Applying patch dll.patch
-- Using source at /usr/local/share/vcpkg/buildtrees/mpfr/src/mpfr-4-8955d4bc66.clean
-- Getting CMake variables for x64-linux-dbg
-- Getting CMake variables for x64-linux-rel
-- Generating configure for x64-linux
-- Finished generating configure for x64-linux
-- Configuring x64-linux-dbg
-- Configuring x64-linux-rel
-- Building x64-linux-dbg
-- Installing x64-linux-dbg
-- Building x64-linux-rel
-- Installing x64-linux-rel
-- Fixing pkgconfig file: /usr/local/share/vcpkg/packages/mpfr_x64-linux/lib/pkgconfig/mpfr.pc
-- Fixing pkgconfig file: /usr/local/share/vcpkg/packages/mpfr_x64-linux/debug/lib/pkgconfig/mpfr.pc
-- Installing: /usr/local/share/vcpkg/packages/mpfr_x64-linux/share/mpfr/copyright
-- Performing post-build validation
-- Performing post-build validation done
Stored binary cache: /home/runner/.cache/vcpkg/archives/9f/
Building package mpfr[core]:x64-linux... done
Installing package mpfr[core]:x64-linux...
Installing package mpfr[core]:x64-linux... done
Elapsed time for package mpfr:x64-linux: 1.177 min

Here is the workflow I use:

- name: Cache vcpkg
      uses: actions/cache@v2
      id: cache-vcpkg
        path: $HOME/.cache/vcpkg
        key:  ${{ runner.os }}-vcpkg
        restore-keys: ${{ runner.os }}-vcpkg

This only works once, when I change the key and restore-keys. Thereafter, the cache hit “succeeds” but only retrieves 22 bytes, far less than what the actual cache would be:

The result is that no cached archives are actually found, and so they are rebuilt on every single workflow, e.g.:

This is a tremendous waste of time and build minutes. My project uses 116 libraries and it takes 11 minutes or so to rebuild.

When caching works, this reduces to 14 seconds.

How do I get this to work reliably?