danielthepope / trntxt

:steam_locomotive::train::train: A data-friendly UK train times site
https://trntxt.uk
MIT License
36 stars 9 forks source link

favicon image buffers #41

Closed benfoxall closed 7 years ago

benfoxall commented 7 years ago

This changes the way that dynamic favicons are served.

Rather than writing the file to disk and serving from there a file buffer is sent directly to the client.

It should be a bit more efficient/nicer for the server and avoids a bunch of assets being dumped in the project.

danielthepope commented 7 years ago

Cool idea! As much as I like the idea of not having loads of assets dumped in my project, I think I already have the lowest load on the server by returning previously generated files. I think what you've done would beat my current implementation on first load, but yours will reconstruct the icon every time, so >100ms every time. By returning from the file system, images were returned (running locally) much faster, between 10-50ms. So I'd prefer to continue serving from files, but #42 has given me an idea. Comment incoming...

benfoxall commented 7 years ago

Ah, I hadn't seen that you were checking for the files to exist - thought they were being generated each time. (makes more sense why you're saving them now.)

I still kind of think avoiding using the filesystem as a cache could be a good plan; makes the app less stateful. Have you thought about using some kind of CDN or caching layer?