Cache in Web Applications

For Markdown, you can render and store in another field.

field :body
field :body_html

Markdown files could be very big, store them in Redis/Memcache may not be a good idea because cache store we do not expect them to persist. You can compute the rendered result into another column (body_html).

- cache post do
  ...

def expensive
  Rails.cache.fetch(cache_key, expires_in: 12.hours) do
    # expensive query happens here!
  end
end

fresh_when
expires_in

For your static assets (images, svg). Use Fastly!