File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
app/login/_components/status Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 11"use server" ;
22
33import buildUri from "@/lib/build-uri" ;
4+ import { unstable_cacheLife as cacheLife } from "next/cache" ;
45
56export async function getUpstreamLatency ( ) : Promise < number > {
7+ "use cache" ;
8+ cacheLife ( "minutes" ) ;
9+
610 try {
7- const start = Date . now ( ) ;
11+ const start = performance . now ( ) ;
812
9- const response = await fetch ( buildUri ( "/" ) , {
10- next : {
11- revalidate : 120 , // update latency every 2 minutes
12- } ,
13- } ) ;
13+ const response = await fetch ( buildUri ( "/" ) ) ;
1414 if ( ! response . ok ) {
1515 return - 1 ;
1616 }
1717
18- return Date . now ( ) - start ;
18+ return Math . round ( performance . now ( ) - start ) ;
1919 } catch ( error ) {
2020 console . error ( "Error getting upstream status:" , error ) ;
2121 return - 1 ;
You can’t perform that action at this time.
0 commit comments