2013-02-28 54 views
1

我在smarty緩存中遇到問題。當從管理網站更新內容時,我能夠立即查看新內容,但是當我查看主網站中的相同頁面時,我看到的是舊內容而不是新內容。當我清除服務器中的templates_c目錄並刷新主網站時,我第一次看到新的內容。我相信它存在緩存問題。請儘快爲我解決這個問題。謝謝。如何使用php代碼清除smarty templates_c文件夾

+0

除了我的問題,我需要一個知道一個方法來清除templates_c文件夾使用PHP代碼。我有谷歌,並試過它似乎並沒有工作。所以我需要一些專家的意見 – user1965773 2013-02-28 07:02:46

+0

如何clearCache()http ://www.smarty.net/docs/en/api.clear.cache.tpl和clearAllCache()http://www.smarty.net/docs/en/api.clear.all.cache.tpl ? – sofl 2013-02-28 10:15:45

+0

此外,請確保compile_check已啓用(默認啓用)http://www.smarty.net/docs/en/caching.tpl – sofl 2013-02-28 10:30:26

回答

0

像這樣的東西應該做的(我還沒有測試它自己):

<?php 
$path = 'path/to/templates_c'; 
$dir = new DirectoryIterator($path); 
foreach ($dir as $fileinfo) { 
    if ($fileinfo->isFile()) { 
     unlink($fileinfo->getPath()); 
    } 
} 
?> 

順便說一句,是你沒」與取消鏈接(),您可能會誤刪除打交道時非常謹慎文件t意味着到

相關問題