In Deno, what is the best way to simply host static websites?
What is the best way to simply host static/cached files?
Without having to do a read file call every request.
And would this work with Deno Deploy?
10 Replies
Also how much can I optimise , I want the highest possible requests/second.
Thanks, but that is not really what I'm looking for.
It doesn't do caching or anything like that.
I'm better off implementing a system myself maybe.
But what about getting the highest number of requests/second locally?
Bun.serve can do 2x-3x the amount of requests/second, which can't be right.
it does do caching
How?
It sets the appropriate headers automatically to ensure that a browser will not download the same file twice
Behind the scenes,
serveDir
and the CLI that https://deno.land/std/http/file_server.ts provides does the same thing, so you can't go wrong either way.That is not really the same thing, but okay.
That's just status code 304.
It's more complicated than that unfortunately.
serveDir
supports a bunch of caching headers, including https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETagETag - HTTP | MDN
The ETag (or entity tag) HTTP response header is an identifier for a
specific version of a resource. It lets caches be more efficient and save bandwidth, as
a web server does not need to resend a full response if the content was not changed.
Additionally, etags help to prevent simultaneous updates of a resource from overwriting
each othe...
Oh, okay.
But status 304 works.
Well, I only know of it because I accidentally used it and all my code changes did nothing. It took me a while to realise this.