Skip to content

[PERFORMANCE] GitHub API responses not cached server-side, causing repeated identical requests on every dashboard page load #2841

Description

@anshul23102

Problem

Each time the dashboard page loads, the server fires fresh API requests to GitHub for stats (commit counts, PR metrics, streak data) even when the underlying data has not changed. GitHub's REST API has a rate limit of 5,000 requests per hour per authenticated token. A user who refreshes the dashboard frequently, or a deployment with many active users sharing one token, will hit the rate limit and receive degraded responses (HTTP 403) until the window resets.

Steps to Reproduce

  1. Open the dashboard
  2. Observe the network panel: GitHub API calls fire on every page load
  3. Refresh the page 60-70 times in quick succession
  4. Observe HTTP 403 responses with X-RateLimit-Remaining: 0

Proposed Fix

Cache GitHub API responses server-side with a short TTL (5-15 minutes) using Redis or the existing Supabase instance:

const CACHE_TTL = 10 * 60; // 10 minutes in seconds

export async function getCachedGitHubStats(username: string) {
  const cached = await redis.get(`gh:stats:${username}`);
  if (cached) return JSON.parse(cached);
  const fresh = await fetchGitHubStats(username);
  await redis.setex(`gh:stats:${username}`, CACHE_TTL, JSON.stringify(fresh));
  return fresh;
}

Also display the last-refreshed timestamp in the UI so users understand they are viewing cached data.

Complexity: Level 2/3 | Program: GSSOC '26

Metadata

Metadata

Labels

gssoc:assignedGSSoC: Issue assigned to a contributor

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions