Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

A GitHub Actions cache hit on the exact primary key means reuse, not refresh. If the key stays the same, the cache action restores the existing entry and skips saving changed contents under that key. To keep dependency caches aligned with your project, derive the primary key from the lockfile and relevant compatibility inputs, then let the package manager reconcile any older cache restored by a prefix.

Why a cache hit does not update the cache

GitHub cache entries are immutable: GitHub says, “You cannot change the contents of an existing cache.” When the restored cache key exactly matches the run’s primary key, the action does not replace that entry with the current contents of the cached path. The save implementation reports: “Cache hit occurred on the primary key [key], not saving cache.” The placeholder represents the concrete key shown in a workflow log. See GitHub’s dependency caching documentation and the official save implementation.

This is expected behavior when the key still describes compatible data. It becomes a stale-dependency problem when the key fails to change after an input such as a lockfile changes. A static key can therefore keep restoring an older dependency cache indefinitely, while the action has no reason to save a replacement under that same key.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to make dependency changes produce a new cache

Build the primary key from the inputs that determine whether cached data is reusable. For dependencies, that usually includes a hash of the relevant lockfile; include the operating system or other compatibility dimensions when they matter to the cached path. GitHub’s documentation recommends keys based on changing inputs such as a lockfile hash.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
- uses: actions/cache@v4
  id: deps
  with:
    path: <package-manager cache or dependency directory>
    key: ${{ runner.os }}-deps-${{ hashFiles('<lockfile glob>') }}
    restore-keys: |
      ${{ runner.os }}-deps-

This is a pattern, not a universal copy-and-paste workflow. Set path and the lockfile glob to match the project and package manager. GitHub documents setup actions that can manage caching for common ecosystems, including Node, Python, Java, Ruby, Go, and .NET; check whether the relevant setup action already handles caching before adding a separate cache step. Details are in GitHub’s dependency caching reference and the actions/cache README.

What the restore-key fallback does

A restore-key prefix can match an older cache when the lockfile-derived primary key has changed. That is a partial restore, not proof that the cache exactly matches the current dependency inputs. Run the package manager against the current lockfile so it can install, update, or otherwise reconcile dependencies. If the job then completes successfully, the action can save the resulting path under the new primary key.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Diagnose a cache that seems stale or will not save

  1. Read the restore and post-job logs. Look for the exact-primary-key message, “Cache hit occurred on the primary key [key], not saving cache.” That confirms the action found the same primary key and skipped saving because the entry already exists. It does not by itself show that the cached data is incorrect.
  2. Compare the resolved primary key across runs. Check that it changes when the lockfile used by the install step changes. A static key will not track dependency changes. Also check that a hashFiles() glob matches the intended lockfile; a glob that resolves to no relevant file cannot represent changes to that file. GitHub’s examples show lockfile contents changing the generated key: documentation and README.
  3. Check the cache-hit result. In the official action documentation, cache-hit is true for an exact primary-key match and false for a restore-key match. Do not skip dependency installation just because some cache was restored. See the actions/cache README.
  4. If the primary key missed, check whether the job could save. Automatic cache creation after a miss depends on successful job completion. Some low-trust workflows have read-only access to the default-branch cache scope; GitHub documents a warning in such cases while the job continues. Use a trusted workflow to maintain a cache where appropriate, rather than weakening permissions without considering who can influence the workflow and its contents. See GitHub’s documentation.
  5. Check branch scope and cache version. Lookup depends on the key, version, and branch scope. Version metadata includes the cached paths and compression tooling, and sibling branches do not generally share caches. Pull-request caches are scoped to merge refs and are not generally reusable by the base branch or other pull requests. GitHub documents the applicable branch rules in its dependency caching reference and action README.
  6. Check retention and repository storage. GitHub’s documentation, accessed October 7, 2026, says entries not accessed for more than seven days are removed. It also gives a default total storage limit of 10 GB per repository; administrators may configure higher limits, and when the limit is reached GitHub evicts entries by least recent access. See GitHub’s current documentation.

Choose a cache key and fallback deliberately

Strategy What it does When it fits Trade-off
Static key, exact match only Reuses the same entry whenever that key is found; an exact hit does not refresh it. Only when the cached contents remain valid for everything represented by the key. Changes not reflected in the key can leave the workflow restoring outdated contents.
Lockfile-derived key, exact match only Creates a different primary key when the lockfile hash changes. When only an exact match is useful and a miss is acceptable. A changed lockfile will not use an older entry as a starting point.
Lockfile-derived key plus prefix fallback Uses an exact cache when available; otherwise may restore a recent cache with the matching prefix. When the package manager can safely reconcile an older cache against the current lockfile. A partial restore is not an exact dependency match; the install or reconciliation step must still run.

Whichever strategy you choose, include the operating system, toolchain, or other compatibility dimensions when those affect the cached data. Cache identity also depends on the saved paths and compression tooling through the cache version, while branch scope controls visibility; a well-designed key cannot make an out-of-scope or incompatible cache available.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep cache contents safe across workflow trust boundaries

Do not cache credentials, tokens, or other secrets. GitHub warns that users able to open pull requests may be able to access cache contents, and that restoring untrusted cache contents can create code-execution risks when workflows use them. Cache writes from low-trust triggers are restricted in relevant scopes by default. Keep cache-writing workflows within an appropriate trust boundary instead of granting broader write access merely to make a save succeed. See GitHub’s dependency caching security and scope guidance.

Rank #3
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What the 23-day stale-CI report establishes

In a 2026 article, author jidonglab reports a cache that was stale for 23 days, an install-time change from 38 seconds to 2 minutes 51 seconds, and a later 36-second run. Those are the author’s case-study figures, not independently verified measurements or a GitHub-wide benchmark. The incident illustrates how a key that does not change can perpetuate reuse; it does not mean every exact cache hit is stale. An exact hit is appropriate when the cached data remains valid for the inputs represented by that key. Read the author’s report.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.