LowellObservatory / NightWatch

A system to display a set of important information at an observatory.
2 stars 0 forks source link

Cache all static assets #20

Closed astrobokonon closed 5 years ago

astrobokonon commented 5 years ago

Noticed that it was taking ~37 seconds to download the 7/14 segment font from fontlibrary.org which is just stupid long. Grab everything needed and put it in the staticfiles directory so we can avoid stuff like that.

Bonus points if we get all the JS that we need, but that might be a bit harder.

astrobokonon commented 5 years ago

The offending (vestigial) call to fontlibrary.org has been removed as of 4eac5b8d603569c25cde72264592dc089266d795, but this is still a good idea to do before putting it into production for real so I'll leave this open.

astrobokonon commented 5 years ago

Tied up in this is the question of whether I should be using bokeh.embed from server_document or components; looking at the docs:

server_document: Return a script tag that embeds content from a Bokeh server

components: Return HTML components to embed a Bokeh plot. The data for the plot is stored directly in the returned HTML...The returned components assume that BokehJS resources are already loaded.

So I think that means I should switch to components, and manually link/include the necessary JS stuff in the template. But my first attempt at that (dc2db3b0c06bd7bad8cfbcefa445cb32d45feb42) was a big fail, so I need to test locally again and use the debugger to see what's actually coming back and why it failed.

astrobokonon commented 5 years ago

Accomplished the bulk of it by 1f533996efbddf9042c767f24635ecb524ac60b8 but really used them by f0d05bbf2e443a059ee8cd5c1889c33819e3aa5f. Unsurprisingly, it didn't really matter according to the dev console trace.

A good chunk of time is taken up by loading the DCT header image - I really should trim that down to the actual size rather than keeping a huge image and resizing it in the HTML because that's just crazy. The damn thing is ~1MB!

It seems like the GOES images are of a decent enough size. They could of course be smaller, but it doesn't seem like they're sinking the ship mostly because HAniS is loading them asynchronously.

I also really should host jquery locally.

Most of the time is still spent in the autoload.js scripts that server_document slaps into the django template. The thing to try to see if there's a way to reduce is the "Waiting (TTFB)" for the bokeh server stuff. "TTFB" is time-till first byte, so literally just time the browser is twiddling it's thumbs waiting for the server to actually start sending stuff. I don't know if there's a way to reduce it, really, since it seems like I'm pretty close to the best case scenario (as judged by 1/4 of an afternoon googling).

astrobokonon commented 5 years ago

Bulk of this is now done, so I'm content to close. I think I followed as closely to the original requirement of being kind to those with slower connections as much as I can in such an early stage, at least.