Templates cache in Django

in settings.py

TEMPLATE_LOADERS = (
    ('django.template.loaders.cached.Loader', (
        'django.template.loaders.filesystem.Loader',
        'django.template.loaders.app_directories.Loader',
    )),
)

ref:
https://docs.djangoproject.com/en/dev/ref/templates/api/#django.template.loaders.cached.Loader

template fragment caching
https://docs.djangoproject.com/en/dev/topics/cache/#template-fragment-caching

cache template tag 會 cache 整個 block 的「內容」
第二個參數以後是 cache key 字串

{% load cache %}
{% cache 300 repost-card repost.id LANGUAGE_CODE %}

你可以用多個 context 變數來組合出 key
repost-card 相當於是 prefix 字串