weavejester / ring-webjars

Ring middleware to serve assets from WebJars
36 stars 4 forks source link

Automatically serving from jsDelivr CDN #5

Closed chachi closed 7 years ago

chachi commented 7 years ago

How would you feel about making wrap-webjars optionally serve from the jsDelivr CDN?

weavejester commented 7 years ago

What would that do? I mean, why not put the CDN URL in directly?

chachi commented 7 years ago

So you could serve assets locally during development and from CDN in prod without changing app code or having per asset conditionals.

weavejester commented 7 years ago

How do you imagine it working? This library doesn't provide any functions that return a webjars URL. It's purely about hosting the assets.

chachi commented 7 years ago

Thinking out loud a bit here, I have some ideas:

  1. Instead of returning a resource response with the asset, redirect to the CDN.
  2. Rewrite the response to point to the CDN.
  3. Provide functions which return either the asset's path locally or on the CDN.
weavejester commented 7 years ago

(1) saves some bandwidth, but using the CDN directly saves a roundtrip to the server.

What do you mean by (2)?

(3) could perhaps be handled by a more generic library, perhaps based off URL templates.

chachi commented 7 years ago

(1) Yes, indeed. (2) I already don't like this idea. (3) Yes, I think you're right.

Sounds like this could be done better elsewhere. Thanks for the convo!