Set up a kmpkg asset cache
All asset caches are configured through the X_KMPKG_ASSET_SOURCES environment variable. The value
of X_KMPKG_ASSET_SOURCES follows a specific configuration syntax.
In this tutorial you'll learn how to:
Prerequisites
- A terminal
- kmpkg
1 - Create an asset cache directory
kmpkg offers the following asset cache providers:
x-azurl: which is intended to work with Azure Blob Storage containers, but works just as well with other service providers and even local or network filesystems.x-script: which lets you add your own business logic to handle asset caching through a customizable script or executable.
This tutorial uses, x-azurl as the provider to store assets in a local directory in your filesystem using a URL with
the file:// protocol.
You can use these same steps to create an asset cache with Azure Blob Storage. Replace any URL in the tutorial with the URL for your storage and provide a SAS Token for authentication.
- Create a directory to serve as an asset cache location (substitute with any locations of your choosing):
- cmd
- bash
mkdir Z:\kmpkg\asset-cache
mkdir /home/kmpkg/asset-cache
2 - Configure X_KMPKG_ASSET_SOURCES
Next set the value of X_KMPKG_ASSET_SOURCES as follows:
- powershell
- cmd
- cmd-powershell
- bash
$env:X_KMPKG_ASSET_SOURCES="clear;x-azurl,file:///Z:/kmpkg/asset-cache,,readwrite"
Setting environment variables in this manner only affects the current terminal session. To make these changes permanent across all sessions, set them through the Windows System Environment Variables panel.
set "X_KMPKG_ASSET_SOURCES=clear;x-azurl,file:///Z:/kmpkg/asset-cache,,readwrite"
Setting environment variables in this manner only affects the current terminal session. To make these changes permanent across all sessions, set them through the Windows System Environment Variables panel.
This X_KMPKG_ASSET_SOURCES configuration adds the following source strings:
clear, disables any previously configured asset cachex-azurl,file:///Z:/kmpkg/asset-cache,,readwrite, sets a filesystem asset cache, located inZ:\kmpkg\asset-cache, with read-write permissions.
export X_KMPKG_ASSET_SOURCES="clear;x-azurl,file:///home/kmpkg/asset-cache,,readwrite"
Setting environment variables using the
exportcommand only affects the current shell session. To make this change permanent across sessions, add theexportcommand to your shell's profile script (e.g.,~/.bashrcor~/.zshrc).
This X_KMPKG_ASSET_SOURCES configuration adds the following source strings:
clear, disables any previously configured asset cachex-azurl,file:///home/kmpkg/asset-cache,,readwrite, sets a filesystem asset cache, located inhome/kmpkg/asset-cache, with read-write permissions.
Next steps
Here are other tasks to try next: