Skip to content

perf(api): Implement ETag conditional caching and request throttling to reduce GitHub API quota consumption #249

Description

@Dotify71

Problem Statement

Currently, OrgExplorer relies on GitHub REST API calls to fetch repository lists, metrics, and contributor data. While local IndexedDB caching is implemented, expired cache entries trigger full network re-fetches.

For unauthenticated users (limited to 60 requests/hour) and authenticated users (5,000 requests/hour), repeated re-fetching rapidly exhausts GitHub API rate limits, especially when exploring large organizations with dozens of repositories.

Proposed Solution

1. ETag-based Conditional Requests (If-None-Match)

  • Store the ETag header along with cached payloads in IndexedDB (src/services/cache.js).
  • When a cached item expires, send a conditional request using the If-None-Match: <etag> header.
  • If data has not changed, GitHub responds with 304 Not Modified, which costs 0 points against the GitHub rate limit quota.
  • Upon receiving a 304, refresh the local cache TTL and immediately return the stored data without re-downloading the payload.

2. Request Throttling & Batching

  • Throttle sequential/parallel API calls to prevent triggering GitHub secondary rate limits when navigating through repository-heavy organizations.

3. Graceful Rate Limit Handling

  • Read x-ratelimit-remaining and x-ratelimit-reset headers from responses to dynamically adjust UI feedback and throttle rates before hard failures happen.

Files to be Modified

  • src/services/github.js
  • src/services/cache.js

Benefits

  • Prevents unnecessary API quota consumption on recurring visits and stale-check cycles.
  • Significantly speeds up page loads for returning visitors.
  • Provides a smoother and more resilient user experience across the app.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions