論盡蛋
心で書く

Blog


Frontend fragment caching

Today added fragment caching in frontend, including posts, user profiles, and portfolio entries.

Before the fragment caching, rendering a post takes these steps:

  1. retrieve the object(s) from database
  2. parse the markdown content to HTML output
  3. just output those meta (author, tags, etc) and the content

But now, the above would only do normally 1 time only. Although the cache that are too old might be deleted due to the memory limit of the memcache store.

The 2nd time and later, just the cached HTML fragments would be returned (hopefully from memory). However, the retrieval of the posts is still required in order to check if there are any updates. But less time is used for retrieving the tags, translations, and rendering the partials.

*[HTML]: HyperText Markup Language