Badgen.net: The cache: query param to force refresh of the cache

Created on 6 Nov 2018  路  11Comments  路  Source: badgen/badgen.net

It still stunning huge. I don't know is it me or is it Badgen, but mostly always nothing works. Neither F5, neither another browser, neither visiting the page in npm, neither Ctrl+R. I'm not sure if it's the caching for chrome too (i aggressively use much chrome flags). But still, it seems that that's not the problem, because even with another browser it does not refresh them.

I suggest to add a query param that always gives you fresh one, so i will be able to add it to my badge links.

Because currently i'm forced to visit the badge's link directly.

Most helpful comment

@tunnckoCore Just realized that, append any args to the badge url will give you a one-time no cache badge, like https://badgen.net/npm/v/express?092734

With this, you can easily verify if it's cached on badgen.net, or 3rd party api service.

All 11 comments

My guess is Now CDN is caching the response but this can be controlled by badgen by setting cache-control headers.

https://zeit.co/blog/now-cdn

I don't think it's the Now, but yea maybe.

Here's the cache header for live badge:

cache-control: public, max-age=60, stale-while-revalidate=604800, stale-if-error=604800, s-maxage=360
cf-cache-status: MISS

And AFAIK, we may encounter these cache/latency for a live badge to refresh:

  • __Browser Cache__ Controlled by max-age=60, CTRL+R would bypass this;
  • __CDN Cache__ Controlled by s-maxage=360, in seconds. (6 mins);
  • __API Latency__ Some api may not always serve latest data. (e.g, jsDelivr is faster than unpkg.com for fetching package.json, but it's got a much more delay for latest published version than unpkg.com, so I switched back (a1bb0ce8263ed7d7791f967740656da4723b512d) to unpkg.com. But still, unpkg.com has some delay, even npm's cli npm v pkg has 1 minute delay or so for newly published version).

Overall, a new version may have up to 10min (by my estimate) delay from publishing to shown on the badge.

Hi @tunnckoCore do you have any advice on this? If no further action we should take, I'm going to close this issue :D

@tunnckoCore I had an idea that we could add a ?cache=30 to limit the cache age on cdn, but make it 1 second at least internally, for perf's sake.

Make sense. But I currently am not sure if it still an issue. ;d

:D Then just hold this issue for a while. I'm kinda busy recently anyway. Let's revisit it later.

I think we should move out from unpkg. It recently implemented super aggressive cache strategy. And that definitely have an impact, I can't wait for hours (recently updated after 8+ hours), and still not guaranteed even after so many hours.

It's not actually _that_ critical problem. It's just frustrating that badges are showing old versions, when I visit the npm site it also sometimes does not showing latest (or no matter what) version (on the /versions tab) and etc. So, the only way to be sure everything is working is to look at the CI job for publishing to see if _actually everything is published correctly_ and refresh GitHub's Releases tab dozen times.

@tunnckoCore Just realized that, append any args to the badge url will give you a one-time no cache badge, like https://badgen.net/npm/v/express?092734

With this, you can easily verify if it's cached on badgen.net, or 3rd party api service.

Oh cool, I didn't think for that :D

So this can be closed 馃槈

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tunnckoCore picture tunnckoCore  路  4Comments

styfle picture styfle  路  5Comments

tunnckoCore picture tunnckoCore  路  3Comments

papb picture papb  路  3Comments

bjankord picture bjankord  路  3Comments