Skip to content

Commit d217701

Browse files
committed
Reduce Vercel serverless function costs
- Change homepage polling intervals from 20s to 5min for both active users and global stats - Increase active-users API server-side cache from 1min to 5min - Remove getServerSideProps from turing page to eliminate SSR https://claude.ai/code/session_01UGfnsFfXcafbYbt2TuFUVq
1 parent e668b74 commit d217701

3 files changed

Lines changed: 5 additions & 11 deletions

File tree

src/components/Home/HomeHero.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ export const HomeHero: React.FC<Props> = ({ scrollHandler }: Props) => {
133133
// Fetch immediately
134134
fetchGlobalStats()
135135

136-
// Update every 20 seconds
137-
const interval = setInterval(fetchGlobalStats, 20000)
136+
// Update every 5 minutes
137+
const interval = setInterval(fetchGlobalStats, 5 * 60 * 1000)
138138

139139
return () => clearInterval(interval)
140140
}, [])
@@ -149,8 +149,8 @@ export const HomeHero: React.FC<Props> = ({ scrollHandler }: Props) => {
149149
// Fetch immediately
150150
fetchActiveUsers()
151151

152-
// Update every 20 seconds
153-
const interval = setInterval(fetchActiveUsers, 20000)
152+
// Update every 5 minutes
153+
const interval = setInterval(fetchActiveUsers, 5 * 60 * 1000)
154154

155155
return () => clearInterval(interval)
156156
}, [])

src/pages/api/active-users.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type Data = {
88

99
// In-memory cache
1010
let cachedUsers: { value: number; timestamp: number } | null = null
11-
const CACHE_DURATION = 60 * 1000 // 1 minute
11+
const CACHE_DURATION = 5 * 60 * 1000 // 5 minutes
1212

1313
/**
1414
* API endpoint to get active user count from PostHog

src/pages/turing.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,4 @@ const Turing: React.FC<Props> = (props: Props) => {
333333
)
334334
}
335335

336-
export const getServerSideProps = async () => {
337-
return {
338-
props: {},
339-
}
340-
}
341-
342336
export default TuringPage

0 commit comments

Comments
 (0)