TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask PG: Displaying number of comments on HN posts

2 点作者 _gbc大约 11 年前
PG, could you please explain how HN decides when to show&#x2F;hide the total number of comments on a post?<p>When there are 0 comments on a story, the link is shown as &quot;discuss&quot;. The link changes to &quot;1 comment&quot; or &quot;N comments&quot; for N&gt;1. However, at some point, it changes just to &quot;comments&quot; with no number shown.<p>As far as I can tell, the change is independent of the number of comments and there doesn&#x27;t seem to be any particular length of time from when the story was submitted that triggers the change. The behaviour also seems to be different depending on whether you are logged in or not.<p>I know it is only a minor aspect of the site, but I have been curious about how it works for a while. Also, what was the logic (if any) in taking this approach?

3 条评论

dang大约 11 年前
I am not PG either but I believe that wglb is right: the number of comments is shown for items in RAM, but not for items on disk. Recent items are held in RAM, but not all older items are.<p>Changes in behaviour when logged out are likely due to caching. We can cache the logged-out pages more aggressively since they&#x27;re shared by all logged-out users.
wglb大约 11 年前
I am not PG (nor have I been for some time) but I once heard it explained that this is due to the fact that after memory fills up, comments are cached to disk, and this is represented by the &quot;comments&quot; tag rather than the actual count. If someone clicks there, I believe the number will show again.
_gbc大约 11 年前
Thanks wglb and dang. At least now I can stop trying to work out the (non-existent) pattern!