Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Cache ordner ist leer

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
Chimera
Smarty Rookie


Joined: 28 Feb 2007
Posts: 15

PostPosted: Tue Sep 16, 2014 1:30 pm    Post subject: Cache ordner ist leer Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Sep 16, 2014 5:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
Chimera
Smarty Rookie


Joined: 28 Feb 2007
Posts: 15

PostPosted: Wed Sep 17, 2014 5:36 am    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Sep 17, 2014 5:53 am    Post subject: Reply with quote

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
View user's profile Send private message
Chimera
Smarty Rookie


Joined: 28 Feb 2007
Posts: 15

PostPosted: Wed Sep 17, 2014 6:16 am    Post subject: Reply with quote

das gibt "file" zurück!
Back to top
View user's profile Send private message
Chimera
Smarty Rookie


Joined: 28 Feb 2007
Posts: 15

PostPosted: Wed Sep 17, 2014 6:25 am    Post subject: Reply with quote

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
View user's profile Send private message
Chimera
Smarty Rookie


Joined: 28 Feb 2007
Posts: 15

PostPosted: Wed Sep 17, 2014 6:27 am    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Sep 17, 2014 6:50 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP