Dieses Script soll wohl besser sei, da es nur Dateien aus dem Cache nimmt, die laut filemtime neuerer sind als die im Cache.
bei "high loaded Server" wohl die bessere Variante.
PHP-Code:
<?php
if (!function_exists('opcache_get_configuration')) { die('OPCache is not installed/running');}
$data = opcache_get_status();
$expired = array();
if (empty($data['scripts'])) { die('no cached files');}
foreach ($data['scripts'] as $file)
{
if ( !empty($file['timestamp'])
&& !empty($file['full_path'])
&& (!file_exists($file['full_path']) || (int)$file['timestamp']<filemtime($file['full_path']))
)
{
$expired[]=$file['full_path'];
@opcache_invalidate($file['full_path'], true); // @ Prevent Warning: Zend OPcache API is restricted by "restrict_api" configuration directive ....
}
}
echo count($expired),' deleted';
Lesezeichen