Live data from Hacker News

Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs

github.com

21–30 of 119 posts

Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs

#21
post #8

> SPA mode to service 404s as index (200) to support client side routing. Be careful: SPAs can handle 404s client-side. All you need to do is continue to return the 404 result code and include the same exact content that you normally do. Then your SPA recognizes that the route isn't set up and displays the error page.

I could certainly add this as a configuration option! Generally an SPA could do this by simply not having that route and handle accordingly but if it's something people would be interesting it is a quick change. Perhaps make a ticket/PR and I can look into adding it :)

That said, thinking about it - the server has no idea whether a client side route is actually correct.

You could have https://example.com/potato/tomato which will not exist on the server of course, but will be handled by client side JS on /index.html and could be a correct route within the app, so it is safer to 200 it.

SPAs aren't really generally made for SEO also. With something like Astro which is SEO friendly, it could actually return a 200 as expected and a 404 if not.

Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs

#22
post #8

> SPA mode to service 404s as index (200) to support client side routing. Be careful: SPAs can handle 404s client-side. All you need to do is continue to return the 404 result code and include the same exact content that you normally do. Then your SPA recognizes that the route isn't set up and displays the error page.

Yep, returning the wrong HTTP status code is going to confuse a lot of search engines, chat app link previews, and other automated consumers of your SPA, even if you subsequently display the correct error page.

Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs

#23
Considering the latency between the user web browser and the server, does the “extremely low latency on account of caching all files in memory” really matter? The files should already be cached by the OS and using sendfile lets the OS copy the file directly to the network.

Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs

#24
post #11

By the way, is there a really minimal, really fast, reasonably secure, zero-cofig single-binary web server which would only support HTTP GET and just expose all the static content in a given directory over it?

I wrote filed[0] for this. It is VERY fast in terms of low-latency (it doesn't even open the file its serving if it can help it) -- although it doesn't generate a dynamic directory listing, so it may not meet your needs if you want any dynamic content like that. [0] https://filed.rkeene.org/

actually readable C. kudos

Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs

#25

The interesting bit is that the project is using a unikernel instead of Docker, I hope this becomes a trend. https://github.com/radiosilence/nano-web?tab=readme-ov-file#...

It is set up to use both.

Currently working on automating releasing the unikernel OPS package (https://repo.ops.city/v2/packages/radiosilence/show) but I had to submit a patch to the OPS project that needs to be released first (or I can make a custom image to use with GHA to build it with a version from master).

Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs

#26

Can you elaborate "CloudFront doesn't support index pages in subdirectories" and how does it not work? I'm not much into them these days but if I remember correctly in the 4-5 years prior, they just works! In-fact, CloudFront was easier to serve static web assets than serving directly from S3. Or have I misunderstood what you meant?

Yeah maybe I'm misunderstanding what this person is referring to, but cloudfront definitely supports index pages in any directory

When was this added? I recall several years ago having to do this with edge lambdas.

IE the it would happily resolve / to /index.html would be fine, but if you wanted to do /my-dir and have it resolve to /my-dir/index.html it would 404.

Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs

#27

The interesting bit is that the project is using a unikernel instead of Docker, I hope this becomes a trend. https://github.com/radiosilence/nano-web?tab=readme-ov-file#...

It is set up to use both. Currently working on automating releasing the unikernel OPS package ( https://repo.ops.city/v2/packages/radiosilence/show ) but I had to submit a patch to the OPS project that needs to be released first (or I can make a custom image to use with GHA to build it with a version from master).

How has your experience with Nanos unikernel been so far since you started? Have you noticed any benefits over Docker?

Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs

#28
post #23

Considering the latency between the user web browser and the server, does the “extremely low latency on account of caching all files in memory” really matter? The files should already be cached by the OS and using sendfile lets the OS copy the file directly to the network.

I just figured any savings where savings can be made is a good thing, especially if there are zero downsides, plus it means very low CPU usage as it's literally just pulling from RAM without any CPU usage.

It also precaches gzipped and brotli'd versions of sensible files so that it can accept-encoding for a variety of browsers.

Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs

#29

Earlier quoted context omitted.

It is set up to use both. Currently working on automating releasing the unikernel OPS package ( https://repo.ops.city/v2/packages/radiosilence/show ) but I had to submit a patch to the OPS project that needs to be released first (or I can make a custom image to use with GHA to build it with a version from master).

How has your experience with Nanos unikernel been so far since you started? Have you noticed any benefits over Docker?

I mean, I think it's an interesting approach to and kind of nice to be going back to more PaaS primitives. I haven't used it in production, it does seem extremely quick and kind of simple and nice.

Either way, I figure the more projects that support it natively, the bigger the ecosystem grows and the more data we'll see based on real world usage.

The tooling seems pretty good, though the documentation could do with some improvement (I intend to do more discovery and PR some documentation improvements when I have time).

Re: Show HN: Nano-web – a low latency one binary webserver designed for serving SPAs

#30

Earlier quoted context omitted.

Yeah maybe I'm misunderstanding what this person is referring to, but cloudfront definitely supports index pages in any directory

When was this added? I recall several years ago having to do this with edge lambdas. IE the it would happily resolve / to /index.html would be fine, but if you wanted to do /my-dir and have it resolve to /my-dir/index.html it would 404.

Now that I'm curious because I remember facing no such issues. Cloudfront was my way of testing all of these scenarios to see what happens when the URL endpoint changes, etc. and then move to Akamai to scale up.

Did some quick searches and I think there seems to be some kinks indeed and of course the solutions. Here are a few;

- https://stackoverflow.com/questions/59634922/how-do-i-serve-...

- https://aws.amazon.com/blogs/networking-and-content-delivery...

Update/Edit: I think the setting to use correct S3 Endpoint makes a difference (which was indeed always my default way when I did).

https://stackoverflow.com/questions/31017105/how-do-you-set-...

Post reply on HN