Using Cache Volumes
Cache Volumes offer unparalleled performance for your cache artifacts. They are provisioned as a mount with full read/write access, allowing you to retain arbitrary files and directories in the cache.From GitHub Actions
To get started with Cache Volumes from Namespace runners you need to enable caching in your Runner Profile and addnscloud-cache-action to your workflow.
nscloud-cache-action has native caching support for many common
frameworks. In case your framework is not integrated yet, you can still cache arbitrary paths in
your GitHub Actions workflows, making it compatible with virtually any toolchain. To get started,
simply research the cache location of your framework and instruct Namespace to cache this path.
Using Cache Mounts
Namespace Docker Builders offer high-performance cold builds, and come with maximum caching builtin - no additional setup required. You can still optimize your build definition to also benefit from partial cache hits in case your build inputs change. A common strategy to improve your build performance is the adoption of build cache mounts, allowing you to persist cache data across container builds and reduce build times significantly.Framework-Specific Examples
Python with pip
This example copiesrequirements.txt first, to ensure that code changes do not lead to a cache miss.
In case dependencies are added to requirements.txt, the usage of the cache mount ensures that the pip cache is retained across builds.
APT packages
You can retain the APT package cache in your Docker cache by mounting/var/cache/apt and /var/lib/apt.
Apt needs exclusive access to its data.
To achieve this, you can select sharing=locked which makes concurrent builds wait for another.
Go Applications
For Go applications, it is recommended to copygo.mod and go.sum first, to ensure that code changes do not lead to a cache miss.
In case dependencies are added, the usage of the cache mount ensures that the go module cache is kept.
Using the HTTP Cache API
If your build tool supports HTTP-based remote caching, you can integrate it with Namespace’s managed build cache using the HTTP Cache API. TheEnsureHttpCache RPC provisions a cache and returns a WebDAV endpoint URL with short-lived credentials (username/password):
PUT and GET with basic auth: