Ticket #13014: 13014_doc.diff

File 13014_doc.diff, 1.4 KB (added by anonymous, 15 years ago)
  • docs/topics/cache.txt

     
    434434It's perfectly fine to specify more than one argument to identify the fragment.
    435435Simply pass as many arguments to ``{% cache %}`` as you need.
    436436
     437.. versionadded:: 1.2
     438
     439If :setting:`USE_I18N` is set to ``True`` then the generated cache keys from
     440the per-site middleware cache will include the name of the active
     441:term:`language<language code>`. This allows you to easily cache multilingual
     442sites without having to create the cache key yourself. For the ``cache``
     443template tag you could use the following code to imitate this behaviour::
     444
     445    {% load i18n %}.
     446    {% load cache %}
     447    {% get_current_language as LANGUAGE_CODE %}
     448    {% cache 60 welcome LANGUAGE_CODE %}
     449        {% trans "Welcome to example.com" %}
     450    {% endcache %}
     451
    437452The cache timeout can be a template variable, as long as the template variable
    438453resolves to an integer value. For example, if the template variable
    439454``my_timeout`` is set to the value ``600``, then the following two examples are
     
    813828runs *first* during the request phase. The ``FetchFromCacheMiddleware`` also
    814829needs to run after other middleware updates the ``Vary`` header, so
    815830``FetchFromCacheMiddleware`` must be *after* any item that does so.
    816 
Back to Top