src/services/HtmlcacheService.php
public function createCacheFile()
    {
        // check if valid to create the file
        if ($this->canCreateCacheFile() && http_response_code() == 200) {
            $cacheEntry = HtmlCacheCache::findOne(['uri' => $this->uri, 'siteId' => $this->siteId]);
            // check if entry exists and start capturing content
            if ($cacheEntry) {
                $content = ob_get_contents();
                if($this->settings->optimizeContent){
                    $content = implode("\n", array_map('trim', explode("\n", $content)));
                }
                $file = $this->getCacheFileName($cacheEntry->uid);
                $fp = fopen($file, 'w+');
                if ($fp) {
                    fwrite($fp, $content);
                    fclose($fp);
                } else {
                    \Craft::info('HTML Cache could not write cache file "' . $file . '"');
                }
            } else {
                \Craft::info('HTML Cache could not find cache entry for siteId: "' . $this->siteId . '" and uri: "' . $this->uri . '"');
            }
        }
    }
public function createCacheFile()
    {
        // check if valid to create the file
        if ($this->canCreateCacheFile() && http_response_code() == 200) {
            $cacheEntry = HtmlCacheCache::findOne(['uri' => $this->uri, 'siteId' => $this->siteId]);
            // check if entry exists and start capturing content
            if ($cacheEntry) {
                $content = ob_get_contents();
                if($this->settings->optimizeContent){
                    $content = implode("\n", array_map('trim', explode("\n", $content)));
                }
                $file = $this->getCacheFileName($cacheEntry->uid);
                $fp = fopen($file, 'w+');
                if ($fp) {
                    fwrite($fp, $content);
                    fclose($fp);
                } else {
                    \Craft::info('HTML Cache could not write cache file "' . $file . '"');
                }
            } else {
                \Craft::info('HTML Cache could not find cache entry for siteId: "' . $this->siteId . '" and uri: "' . $this->uri . '"');
            }
        }
    }
public function createCacheFile ( ) { // check if valid to create the file
 if ( $ this -> canCreateCacheFile ( ) && http_response_code ( ) == 200 ) { $ cacheEntry = HtmlCacheCache :: findOne ( [ 'uri' => $ this -> uri , 'siteId' => $ this -> siteId ] ) ; // check if entry exists and start capturing content
 if ( $ cacheEntry ) { $ content = ob_get_contents ( ) ; if ( $ this -> settings -> optimizeContent ) { $ content = implode ( "\n" , array_map ( 'trim' , explode ( "\n" , $ content ) ) ) ; } $ file = $ this -> getCacheFileName ( $ cacheEntry -> uid ) ; $ fp = fopen ( $ file , 'w+' ) ; if ( $ fp ) { fwrite ( $ fp , $ content ) ; fclose ( $ fp ) ; } else { \ Craft :: info ( 'HTML Cache could not write cache file "' . $ file . '"' ) ; } } else { \ Craft :: info ( 'HTML Cache could not find cache entry for siteId: "' . $ this -> siteId . '" and uri: "' . $ this -> uri . '"' ) ; } } }
Create the cache file

@return void
Create the cache file