Repository: anuraghazra/github-readme-stats
Pull request #2211 (2022-10-18 16:05:40)

fix: improve error caching behavoir
This commit ensures that the cache is not cached when the GraphQL limit is hit in all browsers (see https://stackoverflow.com/a/2068407/8135687 and https://github.com/anuraghazra/github-readme-stats/issues/1471#issuecomment-1282630614).

vercel[bot]: **The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Updated |
| :--- | :----- | :------ | :------ |
| **github-readme-stats** | ✅ Ready ([Inspect](https://vercel.com/github-readme-stats-team/github-readme-stats/75NGHk1kPPTz3tQA8cqJuVwXzShd)) | [Visit Preview](https://github-readme-stats-git-improve-64390e-github-readme-stats-team.vercel.app) | Oct 18, 2022 at 4:05PM (UTC) |


codecov[bot]: # [Codecov](https://codecov.io/gh/anuraghazra/github-readme-stats/pull/2211?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra) Report
Base: **96.65**% // Head: **96.65**% // No change to project coverage :thumbsup:
> Coverage data is based on head [(`f447c54`)](https://codecov.io/gh/anuraghazra/github-readme-stats/pull/2211?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra) compared to base [(`dcc4ccd`)](https://codecov.io/gh/anuraghazra/github-readme-stats/commit/dcc4ccd18cbd24fe1d40780516fb2db17c037c44?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra).
> Patch coverage: 100.00% of modified lines in pull request are covered.

> :exclamation: Current head f447c54 differs from pull request most recent head 1060252. Consider uploading reports for the commit 1060252 to get more accurate results

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master    #2211   +/-   ##
=======================================
  Coverage   96.65%   96.65%           
=======================================
  Files          22       22           
  Lines        3797     3797           
  Branches      323      323           
=======================================
  Hits         3670     3670           
  Misses        125      125           
  Partials        2        2           
```


| [Impacted Files](https://codecov.io/gh/anuraghazra/github-readme-stats/pull/2211?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra) | Coverage Δ | |
|---|---|---|
| [api/index.js](https://codecov.io/gh/anuraghazra/github-readme-stats/pull/2211/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra#diff-YXBpL2luZGV4Lmpz) | `95.78% <100.00%> (ø)` | |
| [api/pin.js](https://codecov.io/gh/anuraghazra/github-readme-stats/pull/2211/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra#diff-YXBpL3Bpbi5qcw==) | `92.59% <100.00%> (ø)` | |
| [api/top-langs.js](https://codecov.io/gh/anuraghazra/github-readme-stats/pull/2211/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra#diff-YXBpL3RvcC1sYW5ncy5qcw==) | `95.12% <100.00%> (ø)` | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/anuraghazra/github-readme-stats/pull/2211?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra).


Patch:
diff --git a/api/index.js b/api/index.js
index 3b5e949..34824ba 100644
--- a/api/index.js
+++ b/api/index.js
@@ -89,7 +89,7 @@ export default async (req, res) => {
       }),
     );
   } catch (err) {
-    res.setHeader("Cache-Control", `no-store`); // Don't cache error responses.
+    res.setHeader("Cache-Control", `no-cache, no-store, must-revalidate`); // Don't cache error responses.
     return res.send(renderError(err.message, err.secondaryMessage));
   }
 };
diff --git a/api/pin.js b/api/pin.js
index 84ca4e6..ef14994 100644
--- a/api/pin.js
+++ b/api/pin.js
@@ -75,7 +75,7 @@ export default async (req, res) => {
       }),
     );
   } catch (err) {
-    res.setHeader("Cache-Control", `no-store`); // Don't cache error responses.
+    res.setHeader("Cache-Control", `no-cache, no-store, must-revalidate`); // Don't cache error responses.
     return res.send(renderError(err.message, err.secondaryMessage));
   }
 };
diff --git a/api/top-langs.js b/api/top-langs.js
index a6a9d28..25f97c8 100644
--- a/api/top-langs.js
+++ b/api/top-langs.js
@@ -76,7 +76,7 @@ export default async (req, res) => {
       }),
     );
   } catch (err) {
-    res.setHeader("Cache-Control", `no-store`); // Don't cache error responses.
+    res.setHeader("Cache-Control", `no-cache, no-store, must-revalidate`); // Don't cache error responses.
     return res.send(renderError(err.message, err.secondaryMessage));
   }
 };
diff --git a/api/wakatime.js b/api/wakatime.js
index 60d22b5..fb8caa5 100644
--- a/api/wakatime.js
+++ b/api/wakatime.js
@@ -78,7 +78,7 @@ export default async (req, res) => {
       }),
     );
   } catch (err) {
-    res.setHeader("Cache-Control", `no-store`); // Don't cache error responses.
+    res.setHeader("Cache-Control", `no-cache, no-store, must-revalidate`); // Don't cache error responses.
     return res.send(renderError(err.message, err.secondaryMessage));
   }
 };


Test patch:
diff --git a/tests/api.test.js b/tests/api.test.js
index c05f25a..f77a717 100644
--- a/tests/api.test.js
+++ b/tests/api.test.js
@@ -180,7 +180,7 @@ describe("Test /api/", () => {
 
     expect(res.setHeader.mock.calls).toEqual([
       ["Content-Type", "image/svg+xml"],
-      ["Cache-Control", `no-store`],
+      ["Cache-Control", `no-cache, no-store, must-revalidate`],
     ]);
   });