Archive Calendar now caches post collections

A minor fix, this. The Archive Calendar on the right over there now has support for caching monthly and daily post collections so that the potentially expensive query plus retrieval from the database doesn't happen every time.

Archives calendar snapshot In essence, since everyone who visits the home page for this blog will generate the current month's calendar, the collection of posts for January will remain in the cache, ensuring rapid access for everyone. Nevertheless, just in case, the cache has an expiration of 10 minutes, so the posts collection for the current month will be queried and generated once every 10 minutes.

This also means that if someone does click the link for the previous month, the collection of posts for that month will only be generated once, despite the page view requiring that collection twice. once for the list of posts and once for the calendar display. Again this is subject to the 10 minute cache expiration.

There is one more change to make, but it can't automatically be done with a Chalk extension. If I add a post (or, for that matter, delete one), the action should remove the collection of posts for the post's month (and date), if present, from the cache. This requires adding an event handler to the "a post was added" event, and this requires a plug-in. After all, Chalk is about creating the data on a page and only executes in that context, so I'm going to guess that the next move is to make the calendar a widget.

Otherwise, the tooltips for each link on a day in the calendar now show the number of posts for that day.

Now playing:
Stranglers - Strange Little Girl
(from The Collection 1977-1982)

Loading similar posts...   Loading links to posts on similar topics...

No Responses

Feel free to add a comment...

Leave a response

Note: some MarkDown is allowed, but HTML is not. Expand to show what's available.

  •  Emphasize with italics: surround word with underscores _emphasis_
  •  Emphasize strongly: surround word with double-asterisks **strong**
  •  Link: surround text with square brackets, url with parentheses [text](url)
  •  Inline code: surround text with backticks `IEnumerable`
  •  Unordered list: start each line with an asterisk, space * an item
  •  Ordered list: start each line with a digit, period, space 1. an item
  •  Insert code block: start each line with four spaces
  •  Insert blockquote: start each line with right-angle-bracket, space > Now is the time...
Preview of response