Install-GoogleFont deletes each downloaded .ttf immediately after installing it, and the clean block removes the temp directory. Any subsequent invocation — whether a retry after a partial failure, a reinstall with -Force, or a separate command targeting overlapping fonts — re-downloads the same files from fonts.gstatic.com.
A small on-disk cache keyed by the asset URL eliminates the duplicate transfers and makes recovery from interrupted batches essentially free. The win is especially large for -All (thousands of files) and for users who script font installs repeatedly across machines.
Request
Current experience
Every run starts from zero. A user who runs Install-GoogleFont -All, hits a transient network error halfway through, and re-runs the command pays the full download cost again for every file already fetched.
Desired experience
Downloaded font files persist in a well-known cache directory. On the next invocation, if the cached file matches the expected URL, it is reused instead of re-fetched. The cache is opt-out, has a clear default location, and grows boundedly.
Acceptance criteria
- Successful downloads are saved into a cache directory
- A second invocation that needs the same URL does not perform a network request
- Cache lookup is keyed by URL (which encodes the version path segment, e.g.
/v23/), so a future Google Fonts metadata update that ships a same-named file at a new URL is not served stale content
-Force bypasses the cache and re-downloads
- The cache location is documented and discoverable via verbose output
Related
- The companion NerdFonts cache issue tracks the same idea for the sibling module
Technical decisions
Cache location: Under the platform-appropriate user cache directory:
- Windows:
$Env:LOCALAPPDATA\PSModule\GoogleFonts\cache
- Linux:
$Env:XDG_CACHE_HOME ?? $HOME/.cache + /PSModule/GoogleFonts
- macOS:
$HOME/Library/Caches/PSModule/GoogleFonts
Cache key: Hash of the asset URL (e.g. SHA-256 truncated to 16 hex chars) joined with the original filename, so two URLs that happen to share a filename do not collide. URLs already embed a version segment (/v23/), so cache entries naturally rotate when Google publishes a new font version.
Validation: Trust the URL-keyed path. Google Fonts CDN URLs are effectively immutable per version. A failed Install-Font after extraction can fall back to re-downloading.
Bypass: Reuse -Force to mean "ignore the cache and re-download". No new parameter required for the first iteration.
Eviction: Out of scope for this issue — the cache grows monotonically. A follow-up can add LRU eviction or a Clear-GoogleFontCache command if the directory becomes a problem.
Implementation plan
Install-GoogleFontdeletes each downloaded.ttfimmediately after installing it, and thecleanblock removes the temp directory. Any subsequent invocation — whether a retry after a partial failure, a reinstall with-Force, or a separate command targeting overlapping fonts — re-downloads the same files fromfonts.gstatic.com.A small on-disk cache keyed by the asset URL eliminates the duplicate transfers and makes recovery from interrupted batches essentially free. The win is especially large for
-All(thousands of files) and for users who script font installs repeatedly across machines.Request
Current experience
Every run starts from zero. A user who runs
Install-GoogleFont -All, hits a transient network error halfway through, and re-runs the command pays the full download cost again for every file already fetched.Desired experience
Downloaded font files persist in a well-known cache directory. On the next invocation, if the cached file matches the expected URL, it is reused instead of re-fetched. The cache is opt-out, has a clear default location, and grows boundedly.
Acceptance criteria
/v23/), so a future Google Fonts metadata update that ships a same-named file at a new URL is not served stale content-Forcebypasses the cache and re-downloadsRelated
Technical decisions
Cache location: Under the platform-appropriate user cache directory:
$Env:LOCALAPPDATA\PSModule\GoogleFonts\cache$Env:XDG_CACHE_HOME ?? $HOME/.cache+/PSModule/GoogleFonts$HOME/Library/Caches/PSModule/GoogleFontsCache key: Hash of the asset URL (e.g. SHA-256 truncated to 16 hex chars) joined with the original filename, so two URLs that happen to share a filename do not collide. URLs already embed a version segment (
/v23/), so cache entries naturally rotate when Google publishes a new font version.Validation: Trust the URL-keyed path. Google Fonts CDN URLs are effectively immutable per version. A failed
Install-Fontafter extraction can fall back to re-downloading.Bypass: Reuse
-Forceto mean "ignore the cache and re-download". No new parameter required for the first iteration.Eviction: Out of scope for this issue — the cache grows monotonically. A follow-up can add LRU eviction or a
Clear-GoogleFontCachecommand if the directory becomes a problem.Implementation plan
-Forceis not setInvoke-WebRequestcall