| Server IP : 159.203.156.69 / Your IP : 216.73.217.172 Web Server : nginx/1.24.0 System : Linux main-ubuntu 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/tanviranik.com/node_modules/vinext/dist/server/ |
Upload File : |
{"version":3,"file":"cache-control.js","names":[],"sources":["../../src/server/cache-control.ts"],"sourcesContent":["export const NEVER_CACHE_CONTROL = \"private, no-cache, no-store, max-age=0, must-revalidate\";\n\nexport const STATIC_CACHE_CONTROL = \"s-maxage=31536000, stale-while-revalidate\";\n\nconst STALE_REVALIDATE_CACHE_CONTROL = \"s-maxage=0, stale-while-revalidate\";\n\nexport const NO_STORE_CACHE_CONTROL = \"no-store, must-revalidate\";\n\n/**\n * Matches Next.js's `getCacheControlHeader` stale window semantics while\n * preserving vinext's legacy unbounded SWR header when no expire ceiling is\n * available yet.\n *\n * Next.js source:\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/cache-control.ts\n */\nexport function buildRevalidateCacheControl(\n revalidateSeconds: number,\n expireSeconds?: number,\n): string {\n if (expireSeconds === undefined) {\n return `s-maxage=${revalidateSeconds}, stale-while-revalidate`;\n }\n\n // `expire <= revalidate` is a zero-width stale window: downstream caches\n // should refetch after s-maxage instead of serving stale.\n if (revalidateSeconds >= expireSeconds) {\n return `s-maxage=${revalidateSeconds}`;\n }\n\n return `s-maxage=${revalidateSeconds}, stale-while-revalidate=${\n expireSeconds - revalidateSeconds\n }`;\n}\n\n/**\n * Builds Cache-Control for ISR cache reads. HIT responses and STALE responses\n * with stored expire metadata use the same route policy because Next.js derives\n * this header from cache-control metadata, not from the cache hit/stale state.\n * STALE entries without expire metadata keep vinext's legacy `s-maxage=0`\n * fallback so older cache entries are not treated as newly fresh downstream.\n */\nexport function buildCachedRevalidateCacheControl(\n cacheState: \"HIT\" | \"STALE\",\n revalidateSeconds: number,\n expireSeconds?: number,\n): string {\n if (revalidateSeconds === Infinity) {\n return STATIC_CACHE_CONTROL;\n }\n\n // When expire is known, match Next.js and emit the route policy even for\n // vinext-served STALE entries. The hard-expire gate has already decided the\n // stale payload is still usable, and downstream caches should see the same\n // finite SWR window Next.js would emit from cacheControl metadata.\n if (cacheState === \"STALE\" && expireSeconds === undefined) {\n return STALE_REVALIDATE_CACHE_CONTROL;\n }\n\n return buildRevalidateCacheControl(revalidateSeconds, expireSeconds);\n}\n"],"mappings":";AAAA,MAAa,sBAAsB;AAEnC,MAAa,uBAAuB;AAEpC,MAAM,iCAAiC;AAEvC,MAAa,yBAAyB;;;;;;;;;AAUtC,SAAgB,4BACd,mBACA,eACQ;CACR,IAAI,kBAAkB,KAAA,GACpB,OAAO,YAAY,kBAAkB;CAKvC,IAAI,qBAAqB,eACvB,OAAO,YAAY;CAGrB,OAAO,YAAY,kBAAkB,2BACnC,gBAAgB;;;;;;;;;AAWpB,SAAgB,kCACd,YACA,mBACA,eACQ;CACR,IAAI,sBAAsB,UACxB,OAAO;CAOT,IAAI,eAAe,WAAW,kBAAkB,KAAA,GAC9C,OAAO;CAGT,OAAO,4BAA4B,mBAAmB,cAAc"}