Details
-
Bug
-
Resolution: Duplicate
-
Medium
-
None
-
3.10.0
-
None
Description
When using static cache, the default configuration uses wget to obtain HTML pages.
By configuring this to the main domain, you get the static cache obtaining the already cached HTML version.
There are different ways to fix it up :
- creating a specific domain without static rewrite rule
- adding specific RewriteCond to exclude requests from your own server
- make sure tu delete static file before generation
I do prefer the last one which is compatible for every config
ezstaticcache.php : storeCache
/*! \private Stores the static cache for \a $url and \a $hostname by fetching the web page using fopen() and storing the fetched HTML data. \param $url The URL to cache, e.g \c /news \param $hostname The name of the host which serves web pages dynamically, see hostName(). \param $staticStorageDir The base directory for storing cache files, see storageDirectory(). \param $alternativeStaticLocations An array with additional URLs that should also be cached. \param $skipUnlink If \c true it will not unlink existing cache files. */ function storeCache( $url, $hostname, $staticStorageDir, $alternativeStaticLocations = array(), $skipUnlink = false, $delay = true ) { if ( is_array( $this->CachedSiteAccesses ) and count ( $this->CachedSiteAccesses ) ) { $dirs = array(); foreach ( $this->CachedSiteAccesses as $dir ) { $dirs[] = '/' . $dir ; } } else { $dirs = array (''); } foreach ( $dirs as $dir ) { $cacheFiles = array(); if ( !is_dir( $staticStorageDir . $dir ) ) { eZDir::mkdir( $staticStorageDir . $dir, 0777, true ); } $cacheFiles[] = $this->buildCacheFilename( $staticStorageDir, $dir . $url ); foreach ( $alternativeStaticLocations as $location ) { $cacheFiles[] = $this->buildCacheFilename( $staticStorageDir, $dir . $location ); } /* Store new content */ $content = false; foreach ( $cacheFiles as $file ) { if ( !$skipUnlink || !file_exists( $file ) ) { $fileName = "http://$hostname$dir$url"; if ( $delay ) { $this->addAction( 'store', array( $file, $fileName ) ); } else { /* Generate content, if required */ if ( $content === false ) { //Start of modification @unlink($file); //End of modification $content = @file_get_contents( $fileName ); } if ( $content === false ) { eZDebug::writeNotice( "Could not grab content (from $fileName), is the hostname correct and Apache running?", 'Static Cache' ); } else { $this->storeCachedFile( $file, $content ); } } } } } }
ezstaticcache.php : storeCache
/*! \static This function goes over the list of recorded actions and excecutes them. */ function executeActions() { if (! isset( $GLOBALS['eZStaticCache-ActionList'] ) ) { return; } $fileContentCache = array(); $doneDestList = array(); $ini =& eZINI::instance( 'staticcache.ini'); $clearByCronjob = ( $ini->variable( 'CacheSettings', 'CronjobCacheClear' ) == 'enabled' ); if ( $clearByCronjob ) { include_once( "lib/ezdb/classes/ezdb.php" ); $db =& eZDB::instance(); } foreach ( $GLOBALS['eZStaticCache-ActionList'] as $action ) { list( $action, $parameters ) = $action; switch( $action ) { case 'store': list( $destination, $source ) = $parameters; if ( isset( $doneDestList[$destination] ) ) continue 2; if ( $clearByCronjob ) { $param = $db->escapeString( $destination . ',' . $source ); $db->query( 'INSERT INTO ezpending_actions( action, param ) VALUES ( \'static_store\', \''. $param . '\' )' ); $doneDestList[$destination] = 1; } else { if ( !isset( $fileContentCache[$source] ) ) { //start modification @unlink($destination); //End modification $fileContentCache[$source] = @file_get_contents( $source ); } if ( $fileContentCache[$source] === false ) { eZDebug::writeNotice( 'Could not grab content, is the hostname correct and Apache running?', 'Static Cache' ); } else { eZStaticCache::storeCachedFile( $destination, $fileContentCache[$source] ); $doneDestList[$destination] = 1; } } break; } } $GLOBALS['eZStaticCache-ActionList'] = array(); }
Attachments
Issue Links
- duplicates
-
EZP-9126 Static cache uses old cache to create new cache on publishing
- Closed