0

I'm a little confused about how to design the caching of a Forum.

For example, considering a threads list:

Title | Author | Last Reply Time | Last Reply User
abcd  |   x    |     12:12       |        y
bcde  |   z    |     23:21       |        m

The list is paginated, say there are 20 threads each page. A simple caching mechanism is to materialized each page on disk. However, when a new thread is added, all the pages' caches have to be updated, since in this case the content of every page is changed. Is there any better approach to cache the threads list so as to avoid frequently removing and re-creating all the cache files?

Hope someone could enlighten me, thanks!

yingzhox
  • 185
  • 2
  • 2
  • 8
  • 1
    why would ALL the pages have to be updated ? – lagbox Apr 28 '14 at 05:43
  • @lagbox because the number of threads in each page is fixed to 20. When a new thread is added, the original #20 thread shown in page 1 is going to be moved to page 2. – yingzhox Apr 28 '14 at 05:47
  • 1
    Most forum software does some degree of server side caching (e.g., keeping a running tally for the number of replies in a thread) but lagbox is right there's no reason to update all pages like you propose. Order all threads by Last Reply Time DESC then use MySQL's LIMIT and OFFSET to get the threads for the page you want. Read more here - http://stackoverflow.com/questions/20364349/multiple-pages-using-mysql-limit-offset – mikey_w May 01 '14 at 20:24

0 Answers0