Skip to content

Commit 8c5d42f

Browse files
authored
feat: cache gh responses (#70)
1 parent cf3be2d commit 8c5d42f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/api/utils/githubClient.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,22 @@ export async function githubApiRequest(
155155
headers.set("Authorization", `token ${env.GITHUB_TOKEN}`);
156156
}
157157

158-
// Make the request
158+
// Configure Cloudflare's tiered cache
159+
const cfCacheOptions = {
160+
cacheEverything: true,
161+
cacheTtlByStatus: {
162+
"200-299": 3600, // Cache successful responses for 1 hour
163+
"404": 60, // Cache "Not Found" responses for 60 seconds
164+
"500-599": 0, // Do not cache server error responses
165+
},
166+
};
167+
168+
// Make the request with tiered cache
159169
const response = await fetch(url, {
160170
...options,
161171
headers,
162172
credentials: "omit", // Avoid CORS issues
173+
cf: cfCacheOptions, // Use Cloudflare's tiered cache
163174
});
164175

165176
// Update rate limit info from response headers

0 commit comments

Comments
 (0)