private function isThemeCacheValid()
    {
        if (!$this->cacheFile->exists()) {
            return false;
        }

        $themeDir = $this->app['filesystem']->getDir('themes://' . $this->get('general/theme'));

        // Check the timestamp for the theme's configuration file
        $timestampTheme = 0;
        $themeFile = $themeDir->getFile('theme.yml');
        if ($themeFile->exists()) {
            $timestampTheme = $themeFile->getTimestamp();
        } elseif (($themeFile = $themeDir->getFile('config.yml')) && $themeFile->exists()) {
            /** @deprecated Deprecated since 3.0, to be removed in 4.0. (config.yml was the old filename) */
            $timestampTheme = $themeFile->getTimestamp();
        }

        return $this->cacheFile->getTimestamp() > $timestampTheme;
    }