Page tree
Skip to end of metadata
Go to start of metadata

{{ dynamic }} block. Any code inside dynamic block will be excluded from cache and rendered on each request.

{{ render }} function. It allows to render included sub-templates by separate rendering process with personal cache settings.

Full specification:
{{ render file="template_name" [language=off|language_id] [publication=off|publication_id] [issue=off|issue_id] [section=off|section_id] [article=off|article_id] [params=paremeters] [cache=secs] }}


file: template filename

language: to cache for any language or for a language with language_id (by default the rendered content is cached only for current language)
publication: to cache for any publication or for a publication with publication_id (by default the rendered content is cached only for current publication)
issue: to cache for any issue or for an issue with issue_id (by default  the rendered content is cached only for current issue)
section: to cache for any section or for a section with section_id (by default  the rendered content is cached only for current section)
article: to cache for any article or for an article with article_id (by default  the rendered content is cached only for current article)
params: specify additional parameters
cache: to overwrite the cache settings in template manager

Let's see on example.
Here is the layout of standard section page. 

We need to exclude from caching some dynamic stuff:
1. Most popular list
2. Most commented list
3. External informers
4. Template contains article list pagination.

Let's define some parameters for dynamic stuff:
Most popular article list is defined for issue only.
Most commented article list is defined for all articles in any issue
Informers should be included on each request
Pagination generates links like http://site/en/pub/issue/section/?page=n

Most popular and commented lists should be cached for 600 sec
The main template section.tpl should be cached for 30 days

Let's do it.

The cache lifetime for main template can be defined in Template manager: 

Most popular list:
{{ render file="most_popular.tpl" section=off cache=600 }} Notice: the cache lifetime could be defined via Template manager.

Most commented list:
{{ render file="most_commented.tpl" issue=off section=off cache=600 }}

{{ dynamic }}
{{ php }} inclide 'informer1.php'; {{ /php }}
{{ /dynamic }}

Section article list with pagination:
{{ render file="section_list.tpl" params=$gimme->url->get_parameter("page") }}

On article changing or issue publishing/unpublishing the cache manager cleans outdated cached content automatically. Cleaning algorithm is based on newscoop specific parameters: language, publication, issue, section, article, template, additional params.


Notes from the session held by Andrey on Sourcecamp 2013 - Prague, September 19 2013 (by Ljuba)

  • useful terminal tool: ab - apache bench
  • $ ab http://localhost-wobs/ (slash on the end is mandatory)
  • $ ab -n 10 (10 requests, counts average time for page rendering) -c 10 (10 concurrent connections)
  • if you put 100 instead of 10, it will be too much and the server will crash (or sort of)
  • every change in main template and included template will trigger cache re-creation
  • {{ dynamic }} content {{ /dynamic }} will be rendered on any request. it cannot rely on any code outside of it (for example $vars)
  • {{ render }} uses a bit more resources than include - don't use it if not necessary
  • when the cache is not enabled, render will behave as include 
  • Newscoop vector reads all the params of every request, and those are:
    • Langugae /en/ (id 5)
    • Publication /localhost (id 10)
    • issue /111/
    • section /10/
    • article /123/
    • params /?page=1
  • so for cache mechanism, localhost/en/ translates to newscoop vector 10,5,0,0,0
  • if for example publication param is defined, and the rest is not defined, any change in article from that pub will re-cache the object
  • if you want to keep object cached for certain amount of time (defined in cache parameter), make Newscoop vector impossible to trigger cache expiration (for example, section=12345)

Suggestions for improvements

  • it could include article type 'trigger' so cache expires only when article of certain type is changed
  • for debugging purposes, enable vector output
  • time of the day when the cache should be created
  • No labels


  1. please also work on: cache expires when playlist was changed

    1. Done in 4.4.1 release.