Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    •  
      CommentAuthorfrancois
     
    Hi,

    I try to figure out how to cache the homepage of my site (like http://www.site.com). A cached file in the cache folder is created and rewrited each time I hit the homepage.

    Thxs

    Francois
    •  
      CommentAuthorfrancois
     
    Fix in the class AkCacheHandler

    function _buildCacheId($path, $forcedLanguage = null, $normalize = true)
    {
    if ($path === null) {
    $path = @$_REQUEST['ak'];

    // Fix : Pb with cached homepage
    if ($path==''){
    include_once (AK_LIB_DIR.DS.'AkRouter.php');
    $Map = new AkRouter();
    if(is_file(AK_ROUTES_MAPPING_FILE)){
    include_once(AK_ROUTES_MAPPING_FILE);
    }

    $path = $Map->toParams('/');
    $path = implode('/',$path);
    }

    } else if (is_array($path)) {
    unset($path['lang']);
    $path = $this->_pathFor($path, $normalize);
    } else if (is_string($path)) {
    ;
    }

    $path = ltrim($path,'/');
    if (preg_match('@^([a-z]{2,2}|[a-z]{2,2}_[a-z]{2,2})/.*$@', $path)) {
    $parts = split('/',$path);
    $forcedLanguage = array_shift($parts);
    $path = implode('/',$parts);
    }
    $cacheId = preg_replace('|'.DS.'+|','/',$path);
    $cacheId = rtrim($cacheId,'/');
    $parts = split('/',$cacheId);

    $hasExtension = preg_match('/.+\..{2,4}/',$parts[count($parts)-1]);
    if (!$hasExtension) {
    if (isset($this->_controller)) {
    $cacheId.= '.'.$this->_controller->Request->getFormat();
    } else {
    list($format, $requestPath) = AkRequestMimeType::getFormat($path);
    $cacheId.= '.'.$format;
    }
    }

    $getParameters = $_GET;

    unset($getParameters['ak']);
    if (is_array($this->_include_get_parameters) && !empty($this->_include_get_parameters) && !empty($getParameters)) {
    $cacheableGetParameters = array();
    sort($this->_include_get_parameters);
    foreach ($this->_include_get_parameters as $include_get) {
    if (isset($getParameters[$include_get])) {
    $cacheableGetParameters[] = $include_get .DS.$getParameters[$include_get];
    }
    }
    /**
    * writing cache fragment for the get_params that should be cached
    */
    $this->writeFragment('get_params'.DS.$cacheId,serialize($this->_include_get_parameters));
    $cacheIdGetPart = implode(DS,$cacheableGetParameters);
    $cacheId .= DS . $cacheIdGetPart;
    } else if (!$this->_controller) {
    /**
    * reading cacheable get_parameters and adding them to the cacheId
    */
    if(($useCacheGetParams = $this->readFragment('get_params'.DS.$cacheId))) {
    $useCacheGetParams = unserialize($useCacheGetParams);
    $cacheableGetParameters = array();
    foreach($useCacheGetParams as $p) {
    if(isset($getParameters[$p])) {
    $cacheableGetParameters[]=$p.DS.$getParameters[$p];
    }
    }
    if (!empty($cacheableGetParameters)) {
    $cacheIdGetPart = implode(DS,$cacheableGetParameters);
    $cacheId .= DS . $cacheIdGetPart;
    }
    }
    }
    $cacheId=strlen($cacheId)>$this->_max_url_length?md5($cacheId):$cacheId;
    $cacheId = ($forcedLanguage!=null?$forcedLanguage:$this->_getDefaultLanguageForUser()).DS. $cacheId;
    $this->_lastCacheId = preg_replace('|'.DS.'+|','/',$cacheId);
    return $this->_lastCacheId;
    }
    • CommentAuthordelia
     
    hi francois,
    i am having same problem as you.... did you solve it modifying the _buildCacheId method??