Skip to content

Performance: Implement CDN Cache-Control headers for the API #69

@DamienSable

Description

@DamienSable

📝 Description

Currently, every time a user's GitHub README loads, GitHub's Camo proxy fetches the SVG from our /api/streak endpoint. Without proper HTTP cache headers, we risk burning through Vercel serverless function invocations and hitting GitHub API rate limits.

🎯 What needs to be done

We need to set explicit Cache-Control headers on our Next.js API response. We should use a stale-while-revalidate (SWR) strategy so that the CDN serves a cached SVG instantly, while fetching the fresh data in the background.

📍 Where to look

  • app/api/streak/route.ts (Look at the NextResponse return statement).
  • MDN Web Docs: Cache-Control

✅ Acceptance Criteria

  • The API response includes a header like: Cache-Control: public, s-maxage=14400, stale-while-revalidate=86400 (Cache for 4 hours, revalidate over 24 hours).
  • Ensure that error responses (500s or 404s) do not get cached (or are cached for a very short time, like 60 seconds).

Metadata

Metadata

Assignees

Labels

GSSoC 2026backendServer-side logic, API routes, data fetching, and core application functionalitygood first issueGood for newcomershelp wantedExtra attention is neededperformanceImprovements related to speed, efficiency, caching, and reducing resource usage

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions