Feat: Expire static images after 90 days like R2, and link top images to direct-img in ntfy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 17:58:06 +00:00
co-authored by Claude Opus 5.5
parent c7613c4c09
commit fdbd91aa19
5 changed files with 25 additions and 21 deletions
+4
View File
@@ -1,5 +1,9 @@
// Shared by the worker and scripts/promote.js, so a promoted image's R2 key always matches the one the worker stored.
// How long an image is kept: the R2 bucket's lifecycle rule deletes it then, so the query is searched again, and
// promote.js stops serving it as a static file
export const TTL_SECONDS = 90 * 24 * 60 * 60;
// Highest ?i= per site: 40 on the main site (100 Brave results; a Firecrawl query's ?i= past FIRECRAWL_RESULTS gets
// an AI image), 20 on free.* (~50 Openverse + Wikimedia results) and 1000 on ai.* (each is a new image, so there's no
// list to run out).
+1 -2
View File
@@ -4,10 +4,9 @@ import { freeImageUrls, parseFreeSource, FREE_UA } from "./_utils/free.js";
import { isFlickrPlaceholder } from "./_utils/flickr.js";
import { aiImage, parseAiSource, DEFAULT_AI_SOURCE } from "./_utils/ai.js";
import { surreal } from "./_utils/surreal.js";
import { MAX_INDEX, siteOf, folder, normalizeQuery, cacheKey as keyFor, r2Key as r2KeyFor, sha256 } from "./_utils/keys.js";
import { TTL_SECONDS, MAX_INDEX, siteOf, folder, normalizeQuery, cacheKey as keyFor, r2Key as r2KeyFor, sha256 } from "./_utils/keys.js";
import * as LIMITS from "../public/assets/rate-limit.js";
const TTL_SECONDS = 90 * 24 * 60 * 60;
// How long a failed search keeps serving bad.webp before the query is searched again
const ERR_SECONDS = 24 * 60 * 60;
// How long a search may hold its query's lock; longer than the 20s image deadline plus the search itself