LGF Technical Update - Caching In
To decrease the load on our main server, and help us to better handle peak traffic times on weekdays, we now have a five minute cache on the front page, and a 15 minute cache on individual entry pages that don’t show comments.
Judging from emails I received, some of you have noticed that this results in the comment count and last commenter’s name (at bottom right of each post on the front page) being slightly out of date. Yep. It does get slightly stale, because it’s only generated once every five minutes, instead of every time the page is loaded. I’m thinking about an Ajax-based alternative that will work even in cached pages; it’s on the LGF Makeover to-do list.
Another effect of the caching code is that our user preferences page (that lets you set font faces and sizes) has become worthless, because it was based around server-side code that set those preferences each time the page was loaded. Again, an Ajax-based approach will probably let me reinstate this feature in the future.
Meanwhile, here’s one interesting benefit of the Makeover Project; this embedded SQL code shows the effects of the cache. These are the top ten pages that have been cached; ‘Entry Number’ shows the LGF post number (zero is the front page), ‘Hits’ is how many times the cached version has been loaded, and ‘Misses’ is how many times the cached version expired and had to be regenerated.
(I know. It’s all very, very geeky, isn’t it. But the point is to improve our ability to stay online through the big surges.)
| entry number | hits | misses |
| 0 | 88,009 | 423 |
| 24,853 | 23,361 | 139 |
| 24,760 | 6,779 | 307 |
| 24,855 | 2,184 | 105 |
| 24,840 | 2,163 | 159 |
| 24,845 | 1,764 | 135 |
| 24,856 | 1,063 | 94 |
| 24,841 | 986 | 135 |
| 24,146 | 945 | 210 |
| 24,838 | 811 | 122 |
UPDATE at 3/17/07 6:23:02 pm:
And of course, this wouldn't be LGF if we didn't have the ability to turn off the caching when it isn't necessary. Since weekend traffic is usually manageable, we're now operating in real time.



