Yii2 Smarty Cache Configuration

Hi guys,

I have a question. How do i smarty cache configuration on yii2? for site and for page?

Also this view cache. If cache is active, no process, no database process, direct get html cache. is true?

Sorry for my english :)

Isn’t there to help?

You can set config options of Smarty via ViewRenderer.options property. As far as I know, templates are cached in HTML-like files so unless you’re querying DB in controller prior to rendering, no DB queries will occur.

Thanks for answer. But Are there examples?

You mean examples of setting properties via application config?

Yes. Please.

How i do smarty cache general and special of page(action or controller).

Something like that:




return [

    // ...

    'components' => [

        'view' => [

            'renderers' => [

                'tpl' => [

                    'class' => 'yii\smarty\ViewRenderer',

                    'options' => [

                        'caching' => \Smarty::CACHING_LIFETIME_CURRENT,

                        'cache_lifetime' => 60*60*24, // 1 day

                    ],

                    'cachePath' => '@runtime/Smarty/cache',

                ],

            ],

        ],

    ],

];




As for data, check http://www.yiiframework.com/doc-2.0/guide-caching-overview.html.