←back to thread

257 points pg | 2 comments | | HN request time: 0.431s | source
Show context
rarrrrrr ◴[] No.2121225[source]
Since no one has mentioned it yet - Varnish-cache.org, written by a FreeBSD kernel hacker, has a very nice feature, in that it will put all overlapping concurrent requests for the same cacheable resource "on hold", only fetch that resource once from the backend, then serve the same copy to all. Nearly all the expensive content on HN would be cacheable by varnish. Then you can get it down to pretty close to "1 backend request per content change" and stop worrying about how arbitrarily slow the actual backend server is, how many threads, how you deal with the socket, garbage collection, and all that.
replies(4): >>2121261 #>>2121274 #>>2121319 #>>2122946 #
nuclear_eclipse ◴[] No.2121319[source]
Reverse proxies won't work for HN, because requests for the same resource from multiple users can't use the same results. Not only are certain bits of info customized for the user (like your name/link at the top), but even things like the comments and links are custom per user.

Things like users' showdead value, as well as whether the user is deaded, can drastically change the output of each page. Eg, comments by a deaded user won't show as dead to that user, but they will for everyone else...

replies(5): >>2121335 #>>2121419 #>>2121430 #>>2121544 #>>2122733 #
aonic ◴[] No.2121430[source]
Varnish supports edge side includes. The header bar could be an ESI and the rest of the page could be cached
replies(1): >>2121555 #
nuclear_eclipse ◴[] No.2121555[source]
> and the rest of the page could be cached

Except they can't, for the reasons I mentioned above. Eg, if my account is deaded, when I view a thread with one of my own comments, it looks different than if someone else was viewing that some thread, especially for those of us with or without showdead checked in our profiles.

Its not as straightforward as you would like it to be.

replies(2): >>2121915 #>>2122019 #
1. nitrogen ◴[] No.2122019[source]
The majority of requests probably come from live accounts in good standing or from people not even logged in, so the majority of requests could still be cached.
replies(1): >>2122860 #
2. nkurz ◴[] No.2122860[source]
Interesting point: what percentage of viewers are logged in? I was presuming it was high, but I guess I really don't know.