@@ -75,6 +75,7 @@ export async function GET(request: Request) {
7575 from : customFrom ,
7676 to : customTo ,
7777 refresh,
78+ bypassCache : bypassCacheParam ,
7879 hide_title,
7980 hide_background,
8081 hide_stats,
@@ -105,6 +106,10 @@ export async function GET(request: Request) {
105106 const normalizedView = view as 'default' | 'monthly' | 'heatmap' | 'pulse' ;
106107 const themeName = theme || 'dark' ;
107108
109+ // Treat either ?refresh=true or ?bypassCache=true as a cache-bypass request
110+ const isRefreshRequested = refresh || bypassCacheParam ;
111+ const shouldBypassCache = isRefreshRequested ;
112+
108113 let timezone = 'UTC' ;
109114 if ( tzParam ) {
110115 try {
@@ -241,7 +246,7 @@ export async function GET(request: Request) {
241246 // Fetch Organization Mega-City Data OR Single User Data
242247 if ( org ) {
243248 const orgData = await getOrgDashboardData ( org , {
244- bypassCache : refresh ,
249+ bypassCache : shouldBypassCache ,
245250 from,
246251 to,
247252 } ) ;
@@ -264,7 +269,7 @@ export async function GET(request: Request) {
264269 users . map ( async ( u ) => {
265270 try {
266271 const userData = await fetchGitHubContributions ( u , {
267- bypassCache : refresh ,
272+ bypassCache : shouldBypassCache ,
268273 from,
269274 to,
270275 } ) ;
@@ -290,7 +295,7 @@ export async function GET(request: Request) {
290295 }
291296 } else {
292297 const userData = await fetchGitHubContributions ( user , {
293- bypassCache : refresh ,
298+ bypassCache : shouldBypassCache ,
294299 from,
295300 to,
296301 } ) ;
@@ -301,7 +306,7 @@ export async function GET(request: Request) {
301306
302307 if ( versus ) {
303308 const versusData = await fetchGitHubContributions ( versus , {
304- bypassCache : refresh ,
309+ bypassCache : shouldBypassCache ,
305310 from,
306311 to,
307312 } ) ;
@@ -339,10 +344,14 @@ export async function GET(request: Request) {
339344 const secondsToMidnight = tzParam
340345 ? getSecondsUntilMidnightInTimezone ( timezone )
341346 : getSecondsUntilUTCMidnight ( ) ;
342- const cacheControl = refresh
347+ const cacheControl = isRefreshRequested
343348 ? 'no-cache, no-store, must-revalidate'
344349 : `public, s-maxage=${ secondsToMidnight } , stale-while-revalidate=86400` ;
345350
351+ const cacheStatusHeader = shouldBypassCache
352+ ? `BYPASS, fetched=${ new Date ( ) . toISOString ( ) } `
353+ : 'HIT' ;
354+
346355 const jsonPayload = JSON . stringify ( {
347356 user : targetEntity ,
348357 stats,
@@ -372,7 +381,7 @@ export async function GET(request: Request) {
372381 'Content-Type' : 'application/json' ,
373382 'Cache-Control' : cacheControl ,
374383 ETag : weakEtag ,
375- 'X-Cache-Status' : refresh ? `BYPASS, fetched= ${ new Date ( ) . toISOString ( ) } ` : 'HIT' ,
384+ 'X-Cache-Status' : cacheStatusHeader ,
376385 } ,
377386 } ) ;
378387 }
@@ -406,7 +415,7 @@ export async function GET(request: Request) {
406415 const secondsToMidnight = tzParam
407416 ? getSecondsUntilMidnightInTimezone ( timezone )
408417 : getSecondsUntilUTCMidnight ( ) ;
409- const cacheControl = refresh
418+ const cacheControl = isRefreshRequested
410419 ? 'no-cache, no-store, must-revalidate'
411420 : isHistoricalYear
412421 ? 'public, s-maxage=31536000, immutable'
@@ -432,7 +441,7 @@ export async function GET(request: Request) {
432441 'Cache-Control' : cacheControl ,
433442 'Content-Security-Policy' : SVG_CSP_HEADER ,
434443 ETag : weakEtag ,
435- 'X-Cache-Status' : refresh ? `BYPASS, fetched=${ new Date ( ) . toISOString ( ) } ` : 'HIT' ,
444+ 'X-Cache-Status' : shouldBypassCache ? `BYPASS, fetched=${ new Date ( ) . toISOString ( ) } ` : 'HIT' ,
436445 } ,
437446 } ) ;
438447 } catch ( error : unknown ) {
0 commit comments