lwsjs / local-web-server

A lean, modular web server for rapid full-stack development.
MIT License
1.21k stars 85 forks source link

Default to compress? #50

Closed KyleAMathews closed 8 years ago

KyleAMathews commented 8 years ago

Is there some reason it's not on my default? It adds negligible CPU load and is far and away a "best practice". Just found this after using http-server (which doesn't even offer the option to compress) and really like things so far (--spa rocks) but would be nice to avoid typing -c every time.

75lb commented 8 years ago

hi Kyle.. negligible CPU load on which spec machine? On slower machines with shitty browsers loading big, nasty websites it has a noticeable effect on performance.. generally, sites load faster (by varying degrees) with compression switched off.. i imagine you'd only get a benefit from --compress on terrible network connections.. did you notice otherwise?

anyway, to make --compress the default, run this command:

$ echo '{ "compress": true }' > ~/.local-web-server.json

with this config in your home folder, any invocation of ws will include the compress option.. run ws --config at any point to print what config is in effect.

local-web-server v2 will be ready soon, it's much better.. if you have any ideas or requests, let me know.

KyleAMathews commented 8 years ago

Negligible on my Mac Book Pro w/ Chrome :-)

I definitely see your point that compression is often not appropriate. I guess my angle is I like to replicate production conditions as much as possible while dev-ing and it's a) disconcerting to see network transfer sizes rise so dramatically w/o compression and b) I sometimes simulate poor network conditions w/ Chrome's devtools and having compression enabled for that definitely makes a big difference.

But your ~/.local-web-server.json solution is a perfectly acceptable workaround.

Thanks for the response! Looking forward to v2.

75lb commented 8 years ago

thought you might be on a MBP - yes, it will be negligible on the most powerful laptop available ;)

Compression is a definitely a performance win and should be on-as-default in all cases where network is involved.. but when the server and client are both on the same machine (as is typically the case for ws users) it doesn't serve any purpose at all beside introducing a small overhead..

yeah, it's important to test with typical prod-server configs while developing, experimenting with different caching strategies etc.. v2 will help more with that.. just want to finish jsdoc2md v2 first..