Redmine 1.0 Feature: Caching Text Formatting

Added by Eric Davis on July 20, 2010 in Home Community Code


One of the new features included in Redmine 1.0 is the ability to cache the text formatting. Each time Redmine displays any text markup, like Textile, it has to run the text through a conversion process to get HTML. This means that an issue with 30 comments will run this conversion runs 31 times, once for the issue description and once for each comment.

The Cache Text Formatting feature will take the results of that conversion and save it so the next time that HTML is needed, the conversions can be skipped. By default this is off but it can be turned on by in the Administration Settings with the option "Cache formatted text".

Cache Formatted Text Setting

It uses Ruby on Rails' MemoryStore for caching. This will save the cached data to the memory of the running Ruby process. But it can replaced with any other Cache Store. For example, I just setup a memcached cache for demo.redmine.org using the following configuration:

# config/additional_environment.rb
#
config.gem 'memcached' # For other hosts
# config.gem 'memcached-northscale', :lib => 'memcached' # For Heroku.com
require 'memcached'
config.cache_store = :mem_cache_store, ::Memcached::Rails.new

If you are interested in more details about this feature, checkout issue #4482 and my blog post where I went through how the text formatting works in more detail.