Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol. wisp.place
86
fork

Configure Feed

Select the types of activity you want to include in your feed.

cache the db call for site manifest

+17 -8
+1
apps/hosting-service/src/lib/cache-invalidation.ts
··· 305 305 306 306 cache.delete('redirectRules', `${did}:${rkey}`) 307 307 cache.delete('settings', `${did}:${rkey}`) 308 + cache.delete('siteCache', `${did}:${rkey}`) 308 309 cache.deletePrefix('siteFiles', `${did}:${rkey}:`) 309 310 resetSiteHtmlHotCacheWarmup(did, rkey) 310 311 advanceStreamCursor(streamId)
+2 -1
apps/hosting-service/src/lib/cache-manager.ts
··· 211 211 212 212 // ── Singleton ──────────────────────────────────────────────────────────── 213 213 214 - type CacheNamespace = 'domains' | 'customDomains' | 'settings' | 'handles' | 'redirectRules' | 'siteFiles' 214 + type CacheNamespace = 'domains' | 'customDomains' | 'settings' | 'handles' | 'redirectRules' | 'siteCache' | 'siteFiles' 215 215 216 216 export const cache = new CacheManager<CacheNamespace>({ 217 217 domains: { ttl: 5 * 60_000, maxEntries: 5000 }, ··· 219 219 settings: { ttl: 5 * 60_000, maxEntries: 1000 }, 220 220 handles: { ttl: 10 * 60_000, maxEntries: 5000 }, 221 221 redirectRules: { maxEntries: 1000, maxSize: 10 * 1024 * 1024, estimateSize: (v) => (v as unknown[]).length * 100 }, 222 + siteCache: { ttl: 5 * 60_000, maxEntries: 5000 }, 222 223 // Negative-result cache for per-site fallback files (SPA, custom 404, auto-detected 404 pages). 223 224 // Stores null when a file is confirmed absent so repeated 404 responses don't re-hit S3. 224 225 siteFiles: { ttl: 5 * 60_000, maxEntries: 10_000 },
+14 -7
apps/hosting-service/src/lib/db.ts
··· 189 189 } 190 190 191 191 export async function getSiteCache(did: string, rkey: string): Promise<SiteCache | null> { 192 - const result = await sql<SiteCache[]>` 193 - SELECT did, rkey, record_cid, file_cids, cached_at, updated_at 194 - FROM site_cache 195 - WHERE did = ${did} AND rkey = ${rkey} 196 - LIMIT 1 197 - ` 198 - return result[0] || null 192 + return cache.getOrFetch( 193 + 'siteCache', 194 + `${did}:${rkey}`, 195 + async () => { 196 + const result = await sql<SiteCache[]>` 197 + SELECT did, rkey, record_cid, file_cids, cached_at, updated_at 198 + FROM site_cache 199 + WHERE did = ${did} AND rkey = ${rkey} 200 + LIMIT 1 201 + ` 202 + return result[0] || null 203 + }, 204 + { cacheIf: (v) => v !== null }, 205 + ) 199 206 } 200 207 201 208 export async function listSiteCachesForDid(did: string): Promise<SiteCache[]> {