mdo / github-buttons

Showcase the success of any GitHub repo or user with these simple, static buttons with dynamic counts.

Home Page:https://ghbtns.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve Cloudflare's caching

XhmikosR opened this issue · comments

Right now we don't make full use of Cloudflare's caching. HTML files are not cached by default.

We should look into these:

  1. Cache everything; it should be fine since the code does not change frequently and we can always purge the cache when we release a new version. The default cache is 4 hours but we can change it to something else
  2. Maybe look into ignoring the query strings and cache the file the same? Query strings do not affect the served HTML, only the GitHub API request

I plan to look into the above one thing at a time, in case we break something.

I added a Page Rule which caches github-btn.html regardless of the queries. Currently set browser cache TTL to 30 minutes.

I'll be monitoring things. If anyone notices any issues let me know.

After this change is done, I will look into adding Edge Cache TTL 2 hours after a few days.

I'm going to close this. After the recent changes I made, we get a cache ratio of ~92% which is a pretty big improvement compared to 0.4% 🙂