mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-11-18 01:54:23 +01:00
Merge pull request #915 from tdurieux/feat/shared-blob-cache
perf: deduplicate cached files across projects and track cache reuse
This commit is contained in:
31 files changed
+2107
-42
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import { cacheMetricsReport } from "../../core/cache-observability";
|
||||
import { sharedBlobCache, resultBlobCache } from "../../core/blob-cache";
|
||||
import { AsyncCache } from "../../core/async-cache";
|
||||
import * as os from "os";
|
||||
import { execFile } from "child_process";
|
||||
@@ -88,6 +90,15 @@ router.get("/performance", async (req, res) => {
|
||||
catch { res.json({ available: false, instances: [], routes: [], stages: [] }); }
|
||||
});
|
||||
|
||||
router.get("/cache", async (req, res) => {
|
||||
res.set("Cache-Control", "no-store");
|
||||
try {
|
||||
res.json({ ...cacheMetricsReport(Number(req.query.minutes)), enabled: config.SHARED_CACHE_ENABLED,
|
||||
filesystemSupported: config.STORAGE === "filesystem", source: sharedBlobCache()?.stats() || null,
|
||||
results: resultBlobCache()?.stats() || null });
|
||||
} catch { res.json({ available: false, reason: "The cache index is unavailable", rows: [] }); }
|
||||
});
|
||||
|
||||
function dashboardCache(
|
||||
_req: express.Request,
|
||||
res: express.Response,
|
||||
|
||||
@@ -146,7 +146,8 @@ router.get(
|
||||
anonymizedPath,
|
||||
repo.model.options
|
||||
);
|
||||
res.header("ETag", etag);
|
||||
if (config.SHARED_CACHE_ENABLED) res.vary("Accept-Encoding");
|
||||
res.header("ETag", config.SHARED_CACHE_ENABLED ? `W/${etag}` : etag);
|
||||
// Force the browser to revalidate every time. The previous 210-day
|
||||
// max-age was keyed only on the upstream sha, so editing the
|
||||
// anonymization term list left old anonymizations cached under the
|
||||
|
||||
Reference in new issue
Block a user