Skip to content

Conversation

@ironashram
Copy link
Contributor

@ironashram ironashram commented Dec 23, 2025

Description

This PR adds a simple file based caching mechanism, i've been battling slowness and timeouts for a very long time while using this project in my gh profile and this has made a huge impact.

In my testing i've gone from around 4s for each request to under 100ms (after the first one gets cached obviously). This is currently deployed and used in my own profile with a self hosted Coolify instance.

The existing Dockerfile now creates a cache directory with appropriate permissions for the Apache www-data user. No breaking changes to the current container setup.

File-based caching system is defined in a new module (src/cache.php) that persists contribution stats to disk, reducing GitHub API calls significantly. The cache uses a 24-hour TTL by default, generates unique keys via SHA256 hashes of request parameters, and handles errors gracefully so caching failures never break actual requests.

Request handler integration in index.php now checks for cached stats before hitting the GitHub API. Cache keys account for all relevant request parameters including starting_year, mode, and exclude_days. The HTTP cache headers were also updated from 3 hours to 24 hours to match the file cache duration.

This is extremely beneficial in selfhosted docker scenario, i am not sure it would make any difference in Vercel since storage may not be persistent, anyway it should not break that kind of deployment or have any impact.

Fixes #

Type of change

  • New feature (added a non-breaking change which adds functionality)

How Has This Been Tested?

  • Tested locally with a valid username
  • Deployed successfully to my Coolify instance

Checklist:

  • I have checked to make sure no other pull requests are open for this issue
  • The code is properly formatted and is consistent with the existing code style
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant