perf: persist unfurl cache between deploys via UNFURL_CACHE_DIR
Build & Deploy / build-and-deploy (push) Successful in 2m30s
Build & Deploy / build-and-deploy (push) Successful in 2m30s
CACHE_DIR in unfurl-shortcode.js and manifest path in eleventy.config.js now read UNFURL_CACHE_DIR env var (falls back to .cache/unfurl/ locally). deploy.yml sets UNFURL_CACHE_DIR=/usr/local/git/.cache/unfurl — same persistent runner volume used by OG_CACHE_DIR and sharp binary cache. Without this, every deploy re-fetched all 283 interaction URLs from scratch because .cache/ is gitignored and not preserved between builds.
This commit is contained in:
@@ -128,6 +128,7 @@ jobs:
|
||||
GITEA_INTERNAL_URL: http://127.0.0.1:3000
|
||||
GITEA_ORG: giersig.eu
|
||||
OG_CACHE_DIR: /usr/local/git/.cache/og
|
||||
UNFURL_CACHE_DIR: /usr/local/git/.cache/unfurl
|
||||
|
||||
- name: Deploy via rsync
|
||||
run: |
|
||||
|
||||
+3
-1
@@ -1854,7 +1854,9 @@ export default function (eleventyConfig) {
|
||||
// prefetchUrl() already caches responses on disk; re-calling it for known URLs
|
||||
// is pure overhead. Writing [...urls] (not [...seen, ...newUrls]) intentionally
|
||||
// prunes URLs from soft-deleted posts, preventing unbounded manifest growth.
|
||||
const manifestPath = resolve(__dirname, ".cache", "unfurl-manifest.json");
|
||||
const manifestPath = process.env.UNFURL_CACHE_DIR
|
||||
? resolve(process.env.UNFURL_CACHE_DIR, "manifest.json")
|
||||
: resolve(__dirname, ".cache", "unfurl-manifest.json");
|
||||
let seen = new Set();
|
||||
try {
|
||||
seen = new Set(JSON.parse(readFileSync(manifestPath, "utf-8")));
|
||||
|
||||
@@ -3,7 +3,7 @@ import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
||||
import { resolve } from "path";
|
||||
import { createHash } from "crypto";
|
||||
|
||||
const CACHE_DIR = resolve(import.meta.dirname, "..", ".cache", "unfurl");
|
||||
const CACHE_DIR = process.env.UNFURL_CACHE_DIR || resolve(import.meta.dirname, "..", ".cache", "unfurl");
|
||||
const CACHE_DURATION_MS = 7 * 24 * 60 * 60 * 1000; // 1 week
|
||||
const FAILURE_CACHE_MS = 7 * 24 * 60 * 60 * 1000; // 1 week — YouTube/bot-blocked sites never succeed, no point retrying daily
|
||||
const USER_AGENT = "Mozilla/5.0 (compatible; Indiekit/1.0; +https://getindiekit.com)";
|
||||
|
||||
Reference in New Issue
Block a user