簡體   English   中英

嵌套模板的Smarty緩存問題

[英]Smarty caching problems with nested templates

我在Smarty 3中的嵌套模板中進行緩存時遇到問題。似乎當我執行{include} Smarty會忽略調用方模板的緩存設置。 例如,假設已在控制器中啟用了智能緩存:

在template1.tpl中:

{include file='template2.tpl' nocache}

在template2.tpl中:

{include file='template3.tpl'}

在template3.tpl中

{$smarty.now}

在頁面上顯示的{$smarty.now}值直到未清除緩存時始終等於第一頁可視化的時間,盡管強制不緩存第一個子模板。 這對我來說是一個煩人的問題,因為我需要控制template1.tpl中template2.tpl及其子模板的所有內容的緩存設置。

有優雅的解決方法嗎?

Smarty不會緩存template2的內容(移動{$smarty.now}他們的),但是會緩存template3。 也將其包括在nocache中。

我遇到了同樣的問題,因此我重新設計了模板,因此我可以緩存其中的大部分內容,而僅緩存不需要緩存的部分,這些{nocache} content {/nocache}{nocache} content {/nocache}包圍了

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM