= 300 ) { continue; } // CSS/JS mit "no-cache" bei entfernten Versionsnummern stammt aus unserer eigenen // .htaccess: der Browser fragt nur nach, ob sich die Datei geaendert hat. Kein Befund, // sonst meldet die Regel nach "Jetzt beheben" sofort wieder dasselbe. if ( $revalidate && in_array( $asset['type'], array( 'css', 'js' ), true ) && preg_match( '/\bno-cache\b/', strtolower( (string) $asset['cache_control'] ) ) && ! preg_match( '/\bno-store\b/', strtolower( (string) $asset['cache_control'] ) ) ) { continue; } ++$checked; if ( self::lifetime( $asset ) < (int) Wp360_Speed_Optimizer_Doctor_Thresholds::get( 'browser_cache_min_seconds' ) ) { ++$uncached; } } if ( 0 === $checked || 0 === $uncached ) { return null; } $can_fix = ! empty( $environment['can_write_htaccess'] ); return $this->finding( array( 'impact' => $uncached === $checked ? 'high' : 'medium', 'effort' => $can_fix ? 'click' : 'help', 'risk' => $can_fix ? 'safe' : 'expert', 'fix' => $can_fix ? 'browser_cache' : null, 'data' => array( 'checked' => $checked, 'uncached' => $uncached, ), ) ); } /** * Lebensdauer in Sekunden aus Cache-Control (max-age, s-maxage) oder Expires. * 0 heisst: nicht zwischengespeichert. * * @param array $asset */ private static function lifetime( array $asset ) { $control = strtolower( (string) $asset['cache_control'] ); if ( preg_match( '/\b(no-store|no-cache)\b/', $control ) ) { return 0; } if ( preg_match( '/\b(?:s-maxage|max-age)\s*=\s*(\d+)/', $control, $m ) ) { return (int) $m[1]; } $expires = strtotime( (string) $asset['expires'] ); if ( false === $expires || '' === (string) $asset['expires'] ) { return 0; } $base = '' !== (string) $asset['date'] ? strtotime( (string) $asset['date'] ) : false; return max( 0, $expires - ( false === $base ? time() : $base ) ); } }