View previous topic :: View next topic |
Author |
Message |
Chimera Smarty Rookie
Joined: 28 Feb 2007 Posts: 15
|
Posted: Tue Sep 16, 2014 1:30 pm Post subject: Cache ordner ist leer |
|
|
Hallo,
ich komm leider nicht weiter.
Ich habe das caching in Smarty angeschaltet:
Code: |
self::$instance = new SmartyHelper();
self::$instance->setCaching(Smarty::CACHING_LIFETIME_CURRENT);
self::$instance->setCacheLifetime(36000);
|
doch leider ist der Cache ordner immer leer.
Beim debugging bin ich soweit gekommen, das in der Klasse Smarty_Internal_Template in der methode writeCachedContent die Variable $this->source->recompiled auf true steht und $this->caching auf false.
Ich find aber den Fehler nicht wo ich das anpassen kann.
ich benutze die aktuelle Smarty Version.
Für Hilfe wäre ich dankbar,
Gruß |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Sep 16, 2014 5:54 pm Post subject: |
|
|
Was für ein Source Resource Type wird denn Verwendet? eval: ?
Auf jedenfall scheint die Klasse der Source Resource Child der Klasse Smarty_Resource_Recompiled zu sein. Dieser Resource type kompilert das Template bei jedem Aufruf neu, daher wäre ein caching völlig nutzlos und Smarty disabled das Caching automatisch. |
|
Back to top |
|
Chimera Smarty Rookie
Joined: 28 Feb 2007 Posts: 15
|
Posted: Wed Sep 17, 2014 5:36 am Post subject: |
|
|
Hallo,
ich benutze den Standard type, wird dann eval sein. Was muss denn für ein typ gesetzt werden. Ich hatte das caching bisher immer so eingeschaltet und in der Doku steht es auch so als bsp.
Den Type setzt man so, oder:
Code: | self::$instance->setCachingType(); |
Was übergebe ich dann da?
Ich hatte auch schon eine eigene Klasse verwendet.
self::$instance->setCachingType('file_gzip');
Denn code dazu hatt ich aus dem Forum.
Code: |
<?php
class Smarty_CacheResource_File_Gzip extends Smarty_Internal_CacheResource_File {
/**
* Read the cached template and process its header
*
* @param Smarty_Internal_Template $_template template object
* @param Smarty_Template_Cached $cached cached object
* @return booelan true or false if the cached content does not exist
*/
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached=null)
{
$_smarty_tpl = $_template;
$content = gzinflate(file_get_contents($_template->cached->filepath));
if (isset($content)){
eval("?>" . $content);
return true;
}
return false;
}
/**
* Write the rendered template output to cache
*
* @param Smarty_Internal_Template $_template template object
* @param string $content content to cache
* @return boolean success
*/
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
{
return parent::writeCachedContent($_template, gzdeflate($content));
}
}
|
Da ist aber das gleiche Problem.
Danke und Gruß |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Sep 17, 2014 5:53 am Post subject: |
|
|
Das Problem liegt nicht am Caching Type bzw. Caching selbst.
Das Problem ist der Source Type. Wo kommen die Template Sources denn her?
Was gibt $smarty->getDefaultResourceType(); zurück. Default wäre das 'file' für das File System. Du hast scheinbar eine andere Quelle für die Sources. |
|
Back to top |
|
Chimera Smarty Rookie
Joined: 28 Feb 2007 Posts: 15
|
Posted: Wed Sep 17, 2014 6:16 am Post subject: |
|
|
das gibt "file" zurück! |
|
Back to top |
|
Chimera Smarty Rookie
Joined: 28 Feb 2007 Posts: 15
|
Posted: Wed Sep 17, 2014 6:25 am Post subject: |
|
|
ich bin nun etwas weiter..
mein template sieht so aus:
Code: |
{extends file="page_body.tpl"}
{block name="content"}
Test
{/block}
|
Wenn ich die Vererbung entferne und nur das HTML ausgebe, cached er richtig. |
|
Back to top |
|
Chimera Smarty Rookie
Joined: 28 Feb 2007 Posts: 15
|
Posted: Wed Sep 17, 2014 6:27 am Post subject: |
|
|
ok..
ich habe die Ursache. Im master template (page_body.tpl) hatte ich einen "nocache" block, der sorgt dafür.
Ich dachte es zählz nur für diesen Bereich und nicht global fürs gesamte template?! |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Sep 17, 2014 6:50 am Post subject: |
|
|
Eigentlich sollte nur der {nocache} {/nocache} Bereich nicht gecached werden.
Eventuell liegt eine unglückliche Konstellation von {block} und {nocache} Verschachtelung vor. |
|
Back to top |
|
|