Ticket #13014: 13014_doc.diff
File 13014_doc.diff, 1.4 KB (added by , 15 years ago) |
---|
-
docs/topics/cache.txt
434 434 It's perfectly fine to specify more than one argument to identify the fragment. 435 435 Simply pass as many arguments to ``{% cache %}`` as you need. 436 436 437 .. versionadded:: 1.2 438 439 If :setting:`USE_I18N` is set to ``True`` then the generated cache keys from 440 the per-site middleware cache will include the name of the active 441 :term:`language<language code>`. This allows you to easily cache multilingual 442 sites without having to create the cache key yourself. For the ``cache`` 443 template 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 437 452 The cache timeout can be a template variable, as long as the template variable 438 453 resolves to an integer value. For example, if the template variable 439 454 ``my_timeout`` is set to the value ``600``, then the following two examples are … … 813 828 runs *first* during the request phase. The ``FetchFromCacheMiddleware`` also 814 829 needs to run after other middleware updates the ``Vary`` header, so 815 830 ``FetchFromCacheMiddleware`` must be *after* any item that does so. 816