ambuda icon indicating copy to clipboard operation
ambuda copied to clipboard

Self-host all external JS?

Open shreevatsa opened this issue 3 years ago • 3 comments
trafficstars

Currently, scripts are loaded from a few external sources. E.g. visiting http://localhost:5000/proofing/foo/14/ I see:

Would it make sense to cache them all, maybe bundle them into one, and load them ourselves?

Possible benefits:

  • Privacy (requests not sent to jsdelivr / unpkg / whatever external source)
  • Security and stability (the external website can't change the file under us, to something possibly malicious or broken)
  • Will/can work locally without internet, at least not required on every request.

The last one is of most interest to me, as my 3-year-old keeps disconnecting the internet at home 😄 and I'm typing this from unreliable hotel wi-fi.

Possible disadvantages:

  • Work to set it up
  • More hosting / serving costs
  • May be slower than the CDN

shreevatsa avatar Sep 04 '22 16:09 shreevatsa

I think the pros make sense, and the cons aren't too bad. What I'm curious about is why the CDN versions aren't being cached, as I would expect them all to have long-lived HTTP caches ...

akprasad avatar Sep 04 '22 17:09 akprasad

I think the lack of caching was because of turning off caching in the Network tab of Developer Tools:

image

(Will try without that option…)

shreevatsa avatar Feb 20 '23 17:02 shreevatsa

IIRC developer tool settings usually take place only if the console is open. But, let me know if that works

akprasad avatar Feb 20 '23 19:02 akprasad