mavo icon indicating copy to clipboard operation
mavo copied to clipboard

[plugins] jsDelivr doesn't deliver the latest plugin version

Open DmitrySharabin opened this issue 5 years ago • 13 comments

I released a new version of the Firebase plugin. But when I include it via the mv-plugins attribute, jsDelivr delivers me the old version. Do we have to wait a bit for changes to propagate? What if we use the https://cdn.jsdelivr.net/gh/${plugin.repo}@latest/${filename} URL to include plugins instead? For not to wait.

DmitrySharabin avatar Jun 12 '20 13:06 DmitrySharabin

Yes, we have to wait for the changes to propagate even if we use the @latest suffix (so there is no need to use it). I believe we should warn plugins authors somehow about this jsDelivr “feature” and not make them panic as I was. 😂

DmitrySharabin avatar Jun 13 '20 08:06 DmitrySharabin

How long is the wait?

LeaVerou avatar Jun 14 '20 16:06 LeaVerou

It feels like 12–24 hours.

DmitrySharabin avatar Jun 14 '20 16:06 DmitrySharabin

Oh wow, that's a lot.

LeaVerou avatar Jun 14 '20 21:06 LeaVerou

It looks like jsdelivr might only work with releases, e.g. this link produces a 404: https://cdn.jsdelivr.net/gh/valterkraemer/mavo-firebase/mavo-firebase.js

and the file is not in the directory listing: https://cdn.jsdelivr.net/gh/valterkraemer/mavo-firebase/

I opened an issue in their repo here: https://github.com/jsdelivr/jsdelivr/issues/18225

It looks like we may need to find an alternative if there's no jsdelivr syntax that will give us the latest commit. @DmitrySharabin any ideas?

LeaVerou avatar Jun 15 '20 01:06 LeaVerou

To my mind, we might have two options here.

Plugin authors are skilled enough so they can enable GitHub Pages. If they haven’t done it before, it won't be a big problem for us to give them a link where they can find full instructions on how to do that. So we can deliver plugins from GitHub directly.

Since plugin authors can use custom domains for GitHub Pages or host their plugins somewhere else, we can provide an optional parameter (property) for plugins, e.g., pluginURL. If it's empty, we use the default URL—https://author.github.io/plugin-repo/mavo-plugin-id.js. Otherwise, we use the URL provided by a plugin’s author.

As a fallback (for plugins that are not maintained anymore), we can use the approach we used to have before jsDelivr—embed a plugin’s code directly into HTML.

What do you think?

DmitrySharabin avatar Jun 15 '20 06:06 DmitrySharabin

Yeah, I was wondering about requiring Github Pages. But this doesn't solve anything about existing plugins, many of which are unmaintained so we can't chase down their authors and force them to enable Github Pages. Btw I just pushed a fix that fixes the URL to get the latest commit on master, I wonder if this also addresses the long wait?

LeaVerou avatar Jun 15 '20 13:06 LeaVerou

@latest/no version work with commits too but releases have higher priority, so if a release exists, you have to be explicit. Otherwise, @latest falls back to @master if there are no releases.

That's actually a good heuristic. I wonder whether we should go back to @latest if we can compel @valterkraemer to release a new version with the 10 commits after 2.0.1.

We could also adopt the @ syntax to allow for specific versions of plugins to be used (e.g. mv-plugins="[email protected]").

LeaVerou avatar Jun 15 '20 13:06 LeaVerou

Btw I just pushed a fix that fixes the URL to get the latest commit on master, I wonder if this also addresses the long wait?

We don't have this directly in the docs but here are some details from one of the recent issues:

There's purge API that can be used to force update cache at the CDN edge servers but the files may still be cached for a short time at our origin servers.

The closest you can get to realtime updates is with publishing to npm, using a link like /npm/package/file that references the latest release, and using the purge API to force update the cache right after release. npm releases should be available everywhere within seconds.

A similar thing should work with GitHub releases, where the propagation time is within minutes. When using @branch references, our origin servers may cache individual files for up to 12 hours.

Note that "propagation time is within minutes" applies when you use the purge API, otherwise, there's still the CDN cache (12 hours).

MartinKolarik avatar Jun 15 '20 13:06 MartinKolarik

That's actually a good heuristic. I wonder whether we should go back to @latest if we can compel @valterkraemer to release a new version with the 10 commits after 2.0.1.

Hey, not used Mavo in a long time, so it's hard for me to make improvements to the code because I'm not familiar with it anymore. But I could make a release with existing code if that would help out ☺️

valterkraemer avatar Jun 16 '20 08:06 valterkraemer

@valterkraemer Yup, just a release with the existing code is all that's needed! Thanks Valter!

LeaVerou avatar Jun 16 '20 13:06 LeaVerou

3.0.0 created ☺️

valterkraemer avatar Jun 17 '20 16:06 valterkraemer

TIL: jsDelivr has a tool to help with that — https://www.jsdelivr.com/tools/purge

DmitrySharabin avatar Dec 05 '23 14:12 DmitrySharabin