Check if frontend page is cacheable

@param array|null $conf Configuration
@return bool
961960
public static function isCacheable($conf = null)
    {
        $TSFE = self::getTsfe();

        if ($_SERVER['REQUEST_METHOD'] !== 'GET' || !empty($TSFE->fe_user->user['uid'])) {
            return false;
        }

        // don't parse if page is not cacheable
        if (empty($conf['allowNoStaticCachable']) && !$TSFE->isStaticCacheble()) {
            return false;
        }

        // Skip no_cache-pages
        if (empty($conf['allowNoCache']) && !empty($TSFE->no_cache)) {
            return false;
        }

        return true;
    }
987415
public function isCached() {
    $cache = ObjectFactory::getInstance('staticCache');
    return $this->id == self::NO_CACHE ? false :
            $cache->exists(self::getCacheSection($this->type), self::getCacheId($this->id));
  }
1173515
public static function isCacheEnabled($pBlockConfig)
    {
    	$configCacheName = ConfigInterface::CONFIG_CACHE_NAME;

    	return (is_array($pBlockConfig)
    			and Agl::app()->isCacheEnabled()
    			and isset($pBlockConfig[$configCacheName])
    			and is_array($pBlockConfig[$configCacheName]));
    }
1236653
private function cacheIsExpired($file)
	{
		if(Config::get('@.TEMPLATE_CACHE_ON') && is_file($file))
		{
			return filemtime($file) + Config::get('@.TEMPLATE_CACHE_EXPIRE') < $_SERVER['REQUEST_TIME'];
		}
		else 
		{
			return true;
		}
	}
1212350
protected static function _getStaticCacheDir() {
        $config = Zend_Registry::get('config');
        if (!isset($config->resources->cacheManager->page->backend->options->public_dir)) {
            return false;
        }
        return $config->resources->cacheManager->page->backend->options->public_dir;

        /**
         * Cache dir used to be read from the Front controller, which I would prefer under normal
         * circumstances. But the front controller is not bootstrapped in CLI environment, so I've
         * refactored to read from cache. I'm leaving this for future me to think about some more
         *
         * (full disclaimer: I'm probably never going to think about it anymore)
         *
        $front = Zend_Controller_Front::getInstance();
        if (!$front->getParam('bootstrap')
            || !$front->getParam('bootstrap')->getResource('cachemanager')) {
            Garp_Cli::errorOut('no bootstrap or whatever');
            return false;
        }
        $cacheManager = $front->getParam('bootstrap')->getResource('cachemanager');
        $cache = $cacheManager->getCache(Zend_Cache_Manager::PAGECACHE);
        $cacheDir = $cache->getBackend()->getOption('public_dir');
        return $cacheDir;
         */
    }
1018717
public function isCached($key) {
    if (false != $this->_loadCache()) {
      $cachedData = $this->_loadCache();
      return isset($cachedData[$key]['data']);
    }
  }
1015537
public function getCacheInstance(?string $profile = null, array $options = []): CacheInterface
    {
        $config = $this->config;

        $config = $config->extract('cache');

        $profile = $profile ?: $config->get('default', 'global');

        if ($config->exists('profiles')) {
            $config = $config->extract('profiles.' . $profile);
        }

        $options = array_merge([
            'name' => 'windwalker',
            'storage' => 'array',
            'serializer' => 'php',
            'force_enabled' => false
        ], $config->toArray(), $options);

        return $this->getCache(
            $options['name'],
            $options['storage'],
            $options['serializer'],
            $options
        );
    }
396759
public function isCached($id) {
        if ($id != null) {
            $id = $this->getIDfromOjb($id);
        }

        if ($id == null)
            return false;

        $cachefile = $this->getConfig('cacheDir') . '/' . utf8_decode($id);
        $cachetime = $this->getConfig('cacheTime');

        if (file_exists($cachefile) && time() - $cachetime < fileatime($cachefile)) {
            return true;
        }

        return false;
    }
633219
public function cache($key, $config = 'default')
    {
        if ($this->_type !== 'select' && $this->_type !== null) {
            throw new RuntimeException('You cannot cache the results of non-select queries.');
        }

        return $this->_cache($key, $config);
    }
1269116
private static function cached($actionContext) {
        $httpContext = $actionContext->getHttpContext();
        $request = $httpContext->getRequest();

        // TODO: support POST
        if ($request->isPost()) {
            return false;
        }

        $cacheSettings = InternalHelper::getStaticPropertyValue('\\PhpMvc\\OutputCache', 'settings');
        $actionName = $actionContext->getActionName();

        if (!isset($cacheSettings[$actionName])) {
            $cacheSettings[$actionName] = array();
        }

        if (!isset($cacheSettings['.'])) {
            $cacheSettings['.'] = array();
        }

        if (empty($cacheSettings[$actionName]) && empty($cacheSettings['.'])) {
            return false;
        }

        // location
        if (!empty($cacheSettings[$actionName]['location'])) {
            $location = intval($cacheSettings[$actionName]['location']);
        }
        elseif (!empty($cacheSettings['.']['location'])) {
            $location = intval($cacheSettings['.']['location']);
        }
        else {
            $location = OutputCacheLocation::ANY;
        }

        if (array_search($location, array(OutputCacheLocation::ANY, OutputCacheLocation::SERVER, OutputCacheLocation::SERVER_AND_CLIENT)) === false) {
            return false;
        }

        // vary by parameters
        $params = self::getCacheParams($actionContext, $cacheSettings, 'varyByParam', array_merge($request->get(), $actionContext->getArguments()));

        // vary by headers
        $headers = self::getCacheParams($actionContext, $cacheSettings, 'varyByHeader', $request->headers());

        // vary by custom handlers
        $custom = self::getCacheParams($actionContext, $cacheSettings, 'varyByCustom');

        // check cache
        $response = $httpContext->getResponse();
        $cache = $httpContext->getCache();

        $cacheKey = 'output_' . $request->path() . '_params=' . implode('&', $params) . '_http=' . implode('&', $headers) . '_custom=' . implode('&', $custom);

        if (($cachedResponse = $cache->get($cacheKey)) !== null) {
            $response->setHeaders($cachedResponse['headers']);
            $response->setCookies($cachedResponse['cookies']);
            $response->setStatusCode($cachedResponse['statusCode']);
            $response->setStatusDescription($cachedResponse['statusDescription']);
            $response->writeFile($cachedResponse['files']);
            $response->write($cachedResponse['output']);
            $response->end();
            return true;
        }

        InternalHelper::setPropertyValue($actionContext, 'cacheKey', $cacheKey);

        return false;
    }
512900
private function should_cache_menu( $args ) {

		$should_cache_menu = true;

		if ( ! empty( $args->theme_location ) ) {
			$theme_locations = $this->theme_locations();
			if ( $theme_locations ) {
				$should_cache_menu = in_array( $args->theme_location, $theme_locations, true );
			}
		}

		/**
		 * Filters the caching condition of a single menu.
		 *
		 * @since 1.0.0
		 *
		 * @param bool   $should_cache_menu Whether or not the menu should be cached.
		 * @param object $args              Menu args.
		 */
		return (bool) apply_filters( self::FILTER_SHOULD_CACHE_MENU, $should_cache_menu, $args );
	}
1339389
private function isCached()
    {
        $filters = false;

        if ($this->cacheSettings) {
            if ($this->cache) {
                $filters = $this->cache->getCache();
            }
        }

        return $filters;
    }
476535
public function hasItem($cacheId)
    {
        $cacheId = $this->normalizeKey($cacheId);

        try {
            return $this->cache->hasItem($cacheId);
        } catch (ZendException\ExceptionInterface $ex) {
            return false;
        }
    }
1309227
protected function validCache($value)
    {
        if (is_null($value) || !is_array($value) || empty($value)) {
            return false;
        }

        return true;
    }
996735
public function isCached(Smarty_Internal_Template $_template)
    {
        if ($this->valid !== null) {
            return $this->valid;
        }
        while (true) {
            while (true) {
                if ($this->exists === false || $_template->smarty->force_compile || $_template->smarty->force_cache) {
                    $this->valid = false;
                } else {
                    $this->valid = true;
                }
                if ($this->valid && $_template->caching == Smarty::CACHING_LIFETIME_CURRENT &&
                    $_template->cache_lifetime >= 0 && time() > ($this->timestamp + $_template->cache_lifetime)
                ) {
                    // lifetime expired
                    $this->valid = false;
                }
                if ($this->valid && $_template->smarty->compile_check == 1 &&
                    $_template->source->getTimeStamp() > $this->timestamp
                ) {
                    $this->valid = false;
                }
                if ($this->valid || !$_template->smarty->cache_locking) {
                    break;
                }
                if (!$this->handler->locked($_template->smarty, $this)) {
                    $this->handler->acquireLock($_template->smarty, $this);
                    break 2;
                }
                $this->handler->populate($this, $_template);
            }
            if ($this->valid) {
                if (!$_template->smarty->cache_locking || $this->handler->locked($_template->smarty, $this) === null) {
                    // load cache file for the following checks
                    if ($_template->smarty->debugging) {
                        $_template->smarty->_debug->start_cache($_template);
                    }
                    if ($this->handler->process($_template, $this) === false) {
                        $this->valid = false;
                    } else {
                        $this->processed = true;
                    }
                    if ($_template->smarty->debugging) {
                        $_template->smarty->_debug->end_cache($_template);
                    }
                } else {
                    $this->is_locked = true;
                    continue;
                }
            } else {
                return $this->valid;
            }
            if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED &&
                $_template->cached->cache_lifetime >= 0 &&
                (time() > ($_template->cached->timestamp + $_template->cached->cache_lifetime))
            ) {
                $this->valid = false;
            }
            if ($_template->smarty->cache_locking) {
                if (!$this->valid) {
                    $this->handler->acquireLock($_template->smarty, $this);
                } elseif ($this->is_locked) {
                    $this->handler->releaseLock($_template->smarty, $this);
                }
            }
            return $this->valid;
        }
        return $this->valid;
    }
838757
protected function parseLinkConf(array $conf)
    {
        $uid  = null;
        $type = null;

        // Check link type
        switch ($conf['finalTagParts']['TYPE']) {
            // ##############
            // Page URL
            // ##############
            case 'page':
                if (is_numeric($conf['conf']['parameter'])) {
                    $uid = $conf['conf']['parameter'];
                }

                $type = SitemapUtility::SITEMAP_TYPE_PAGE;
                break;

            // ##############
            // File URL
            // ##############
            case 'file':
                $fileUrl = $conf['finalTagParts']['url'];

                if ($this->checkIfFileIsWhitelisted($fileUrl)) {
                    // File will be registered from the root page
                    // to prevent duplicate urls
                    $uid  = GeneralUtility::getRootPid();
                    $type = SitemapUtility::SITEMAP_TYPE_FILE;
                }
                break;
        }

        return array($uid, $type);
    }
548228
public function main($content, $conf)
    {
        $this->ms = GeneralUtility::milliseconds();

        $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
        $this->conf = $typoScriptService->convertTypoScriptArrayToPlainArray($conf);
        $this->pi_setPiVarDefaults();
        $this->pi_loadLL();

        // Configuring so caching is not expected. This value means that no cHash params are ever set.
        // We do this, because it's a USER_INT object!
        $this->pi_USER_INT_obj = 1;

        // initializes plugin configuration
        $this->init();

        // init template for pi1
        $this->initFluidTemplate();

        // hook for initials
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'] as $_classRef) {
                $_procObj = &GeneralUtility::makeInstance($_classRef);
                $_procObj->addInitials($this);
            }
        }

        // get content for searchbox
        $this->getSearchboxContent();

        // assign variables and do the rendering
        $this->searchFormView->assignMultiple($this->fluidTemplateVariables);
        $htmlOutput = $this->searchFormView->render();

        return $htmlOutput;
    }