views:

122

answers:

2

Or is just saving markdown and rendering it on requests usually okay?

I'm writing a site that uses markdown for content. Stack overflow similarly uses markdown for comments and questions.

I'm storing the content as markdown in the database and then rendering it to html when the user visits the site.

I've got a feeling I ought to be storing the markdown and the html output in the database to cut down the load on the server. However, the performance doesn't seem like an issue now (famous last words.)

It's a rails site using the rdiscount gem to convert the markdown.

+2  A: 

I think it's quite appropriate to store a cached HTML version, but keep the MarkDown as well, just incase you need to either:

  • Display it somewhere else
  • Regenerate the HTML cache, due to some security issue
Noon Silk
+4  A: 

That depends on whether you intend for the Markdown content to be editable. If it's write-once-edit-never, there's no need to keep the source. Otherwise, obviously you need to keep the Markdown.

In most cases, rendering Markdown (at least with a decent library) won't stress a server at all. If server-side processing starts to become an issue, take a look at caching (memcached or similar).

Chuck