You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On PostgreSQL, `INTEGER PRIMARY KEY` becomes `SERIAL`, `DATETIME` becomes `TIMESTAMP`, `INTEGER DEFAULT 0` booleans become `BOOLEAN DEFAULT FALSE`, and size/count columns use `BIGINT`.
@@ -277,6 +291,12 @@ Version age filtering for supply chain attack mitigation. Configurable at global
277
291
278
292
Package metadata enrichment. Fetches license, description, homepage, repository URL, and vulnerability data from upstream registries. Powers the `/api/` endpoints and the web UI's package detail pages.
279
293
294
+
### `internal/mirror`
295
+
296
+
Selective package mirroring for pre-populating the proxy cache. Supports multiple input sources: individual PURLs (versioned or unversioned), CycloneDX/SPDX SBOM files, and full registry enumeration. Uses a bounded worker pool backed by `errgroup` to download artifacts in parallel, reusing `handler.Proxy.GetOrFetchArtifact()` for the actual fetch-and-cache work.
297
+
298
+
The package also provides a `MetadataCache` for storing raw upstream metadata blobs so the proxy can serve metadata responses offline. The `JobStore` manages async mirror jobs exposed via the `/api/mirror` endpoints.
299
+
280
300
### `internal/config`
281
301
282
302
Configuration loading.
@@ -326,10 +346,11 @@ Eviction can be implemented as:
326
346
- Ensures clients fetch artifacts through proxy
327
347
- Alternative: Let clients fetch directly, miss cache opportunity
328
348
329
-
**Why not cache metadata?**
349
+
**Why not cache metadata (by default)?**
330
350
- Simplicity - no invalidation logic needed
331
351
- Fresh data - new versions visible immediately
332
352
- Metadata is small, upstream fetch is fast
353
+
- Set `cache_metadata: true` or use the mirror command to enable metadata caching for offline use via the `metadata_cache` table
333
354
334
355
**Why stream artifacts?**
335
356
- Memory efficient - don't load large files into RAM
Copy file name to clipboardExpand all lines: docs/configuration.md
+59Lines changed: 59 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -213,6 +213,65 @@ Currently supported for npm, PyPI, pub.dev, Composer, Cargo, NuGet, Conda, RubyG
213
213
214
214
Note: Hex cooldown requires disabling registry signature verification since the proxy re-encodes the protobuf payload without the original signature. Set `HEX_NO_VERIFY_REPO_ORIGIN=1` or configure your repo with `no_verify: true`.
215
215
216
+
## Metadata Caching
217
+
218
+
By default the proxy fetches metadata fresh from upstream on every request. Enable `cache_metadata` to store metadata responses in the database and storage backend for offline fallback. When upstream is unreachable, the proxy serves the last cached copy. ETag-based revalidation avoids re-downloading unchanged metadata.
219
+
220
+
```yaml
221
+
cache_metadata: true
222
+
```
223
+
224
+
Or via environment variable: `PROXY_CACHE_METADATA=true`.
225
+
226
+
The `proxy mirror` command always enables metadata caching regardless of this setting.
227
+
228
+
### Metadata TTL
229
+
230
+
When metadata caching is enabled, `metadata_ttl` controls how long a cached response is considered fresh before revalidating with upstream. During the TTL window, cached metadata is served directly without contacting upstream, reducing latency and upstream load.
231
+
232
+
```yaml
233
+
metadata_ttl: "5m" # default
234
+
```
235
+
236
+
Or via environment variable: `PROXY_METADATA_TTL=10m`.
237
+
238
+
Set to `"0"` to always revalidate with upstream (ETag-based conditional requests still avoid re-downloading unchanged content).
239
+
240
+
When upstream is unreachable and the cached entry is past its TTL, the proxy serves the stale cached copy with a `Warning: 110 - "Response is Stale"` header so clients can tell the data may be outdated.
241
+
242
+
## Mirror API
243
+
244
+
The `/api/mirror` endpoints are disabled by default. Enable them to allow starting mirror jobs via HTTP:
245
+
246
+
```yaml
247
+
mirror_api: true
248
+
```
249
+
250
+
Or via environment variable: `PROXY_MIRROR_API=true`.
251
+
252
+
When disabled, the endpoints are not registered and return 404.
253
+
254
+
## Mirror Command
255
+
256
+
The `proxy mirror` command pre-populates the cache from various sources. It accepts the same storage and database flags as `serve`.
257
+
258
+
| Flag | Default | Description |
259
+
|------|---------|-------------|
260
+
| `--sbom` | | Path to CycloneDX or SPDX SBOM file |
261
+
| `--concurrency` | `4` | Number of parallel downloads |
262
+
| `--dry-run` | `false` | Show what would be mirrored without downloading |
0 commit comments