1
2
Fork
You've already forked userscripts
1

Caching in a way that avoids API calls (for reloads) #7

Open
opened 2026年01月10日 02:36:31 +01:00 by jacksonchen666 · 2 comments

Reloads of the same repo means fetching the same thing again. That's a waste of API requests.

Idea: Check the current commit SHA displayed on the front page. Use that and the repository as the "key", store that with GM_setValue, maybe storing the entire notification message (or no message) instead of resulting API requests.

I don't exactly like this very much, because it would rely on scraping the page, and page can change. In case of changes, it would be a good idea to just automatically fallback to fetching the data anyways, disregarding the cache. Do lots of double checking (make sure the SHA is a hex encoded SHA of certain length), etc. and hopefully it's not a problem?

There is also "cache" expiry or whatever. I guess 1 hour? 24 hours? Cache eviction when?

Should it be noted that the result is cached?

Reloads of the same repo means fetching the same thing again. That's a waste of API requests. Idea: Check the current commit SHA displayed on the front page. Use that and the repository as the "key", store that with `GM_setValue`, maybe storing the entire notification message (or no message) instead of resulting API requests. I don't exactly like this very much, because it would rely on scraping the page, and page can change. In case of changes, it would be a good idea to just automatically fallback to fetching the data anyways, disregarding the cache. Do lots of double checking (make sure the SHA is a hex encoded SHA of certain length), etc. and hopefully it's not a problem? There is also "cache" expiry or whatever. I guess 1 hour? 24 hours? Cache eviction when? Should it be noted that the result is cached?
Author
Owner
Copy link

Was doing some #6 and it seemed like GitHub was caching API responses, the rate limits decremented from the exact same number every time, at least with same page and same repos

Was doing some #6 and it seemed like GitHub was caching API responses, the rate limits decremented from the exact same number every time, at least with same page and same repos
Author
Owner
Copy link

Although devving now and it seems like after the cache expires, it does eat into my rate limits

So maybe this could be worth it after all

Although devving now and it seems like after the cache expires, it does eat into my rate limits So maybe this could be worth it after all
Sign in to join this conversation.
No Branch/Tag specified
main
navigation-api
dialog-box
dev
ai-files-gitignore-check
github-ai-use-0.4.0
github-ai-use-0.1
github-ai-use-0.1.1
github-ai-use-0.1.2
github-ai-use-0.1.3
github-ai-use-0.1.4
github-ai-use-0.1.5
github-ai-use-0.1.6
github-ai-use-0.1.7
github-ai-use-0.1.8
github-ai-use-0.1.9
github-ai-use-0.1.10
github-ai-use-0.2.0
github-ai-use-0.3.0
github-ai-use-0.3.1
github-ai-use-0.3.2
github-ai-use-0.3.3
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jacksonchen666/userscripts#7
Reference in a new issue
jacksonchen666/userscripts
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?