TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How Does HackerNews Pagination Work?

11 pointsby wpetersonover 14 years ago
I'm familiar with traditional SQL list pagination (limit/offset) using a page number query parameter.<p>Hackernews seems to generate a token for the next page that has a limited cache/lifetime.<p>Is this a common design pattern? Where can I find more information.

1 comment

pgover 14 years ago
The code that generates list-structured pages spits out a page of n items, then saves a closure that will keep going if asked. Since closures can't conveniently be written to disk, you have to gc them after a while or you'll have a memory leak.<p>It may be overkill to use this approach if you just want to generate the frontpage, but the advantage is that it's very general. You're not limited to displaying a range of items stored in a list somewhere; you could be displaying things you're computing on the fly.
评论 #1808872 未加载
评论 #1809044 未加载