Recently we wanted to add functionality to let our readers comment on the blog articles we post on the YGen Website. After discussing our available options, we chose to use Disqus, a widely used platform for adding comments to any blog.
My initial instinct was to blame caching for the incorrect count, since the previous count that was displayed was accurate. After some investigation I confirmed my suspicion. An inaccurate comment count is annoying but what really bothered me was the fact that when I applied filtering (either by tag or date), the comment count became inconsistent. I ended up in situations where the same article's comment count would be one number on the blog home page and another when filtering by date.
Busting this cached file was relatively simple, I chose to add a hidden "dummy article" comment count based on a variable that will always be different - current time. An example implementation of this in ASP.NET Razor syntax of this would be:
<span class="hidden disqus-comment-count" data-disqus-identifier="@DateTime.UtcNow.Ticks"></span>
This will result in a generated URL such as "count-data.js?1=my-blog-article&2=636282175638532289" and since this URL will never be the same for two requests, it will always give a consistent comment count. This solution does come with a small performance decrease of course since a cached version of this file is no longer retrieved.
So if you too are bothered by an inconsistent comment count for your blog articles, you may consider using this cache busting solution on your own site. Thanks for reading, and if you have any comments or questions, let me know!