Version Badges: Now with Even Shorter Lifespans

Apr 23 2021

Good news! When you're embedding version badges elsewhere, you'll probably have noticed that services like GitHub like to cache them for an excruciatingly long time*, often well beyond the lifetime of the package version itself. That changes today, along with a stylish (yes, stylish, not just style) update:

Couple of things to note:

  • The cache TTL (Time-To-Live) time has been reduced from 86400 seconds (1 day) to 300 seconds (5 mins).
  • You can now generate badges for Docker images that have a version (non-hashref) assigned to them.
  • The latest version badges will now show a "(latest)" prefix; you can turn this off via "show_latest=false".
  • You can now customise the appearance of the badge (see below for more details).
  • We'll now generate a (much) nicer "version not found" badge if a package or version isn't found.

Tweaking the badge appearance:

  • Figure out how you want to tweak it by looking at the official shields attributes.
  • Find the query string in the snippet (near the question mark), and add <attribute>=<value> to it.
  • Don't forget to put an ampersand between your new value and the next part of the string.

For example, why not go for a wild and crazy alternative colour badge?

Finally: A huge thank you to shields.io for providing an amazing badge rendering service! \o/

Note*: This isn't actually GitHub's fault, our previous use of shields.io meant the Cache-Control header was always returning a max-age of 86400. So we migrated to shields.io newer JSON-based endpoint to fix it.

Keep up to date with our monthly product bulletin

By submitting this form, you agree to our privacy policy