Detect if the file should be resent to the client or if it can use its cache

@param string filename requested
@access private
514398
private static function cache($mtime) {
		$gmt_mtime = gmdate('D, d M Y H:i:s', $mtime).' GMT';

		header('Cache-Control: public');
		header('Pragma: public');

		if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
			if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) {
				header('Expires: ');
				HTTP\Status::code_304();
			}
		}

		header('Last-Modified: '. $gmt_mtime);
		header('Expires: '.gmdate('D, d M Y H:i:s', strtotime('+30 minutes')).' GMT');
	}
542269
function size($filename)
    {
        if (!($this->bitmap & SSH2::MASK_LOGIN)) {
            return false;
        }

        $result = $this->stat($filename);
        if ($result === false) {
            return false;
        }
        return isset($result['size']) ? $result['size'] : -1;
    }
450393
public boolean isFresh(final String filename) {
        final FileSystem fileSystem = vertx.fileSystem();

        try {
            FileProps fileProps = fileSystem.propsBlocking(filename);
            LRUCache.CacheEntry<String, T> cacheEntry = cache.get(filename);
            final long lastModified = fileProps.lastModifiedTime();

            if (cacheEntry == null) {
                return false;
            }
            if (cacheEntry.isFresh(lastModified)) {
                return true;
            }
            // not fresh anymore, purge it
            cache.remove(filename);
            return false;
        } catch (RuntimeException e) {
            return false;
        }
    }
136124
private function doesFileChecksFailed(string $file): bool
    {
        //check if file exist
        if (!\file_exists($file)) {
            return true;
        }

        //take cache from file
        $cacheValue = include $file;

        //check if cache is expired and delete file from storage
        if ($cacheValue['expires'] <= \time() && $cacheValue['expires'] !== 0) {
            \unlink($file);

            return true;
        }

        return false;
    }
146343
function isFile( $filename = false )
    {
        if ( !$filename )
            $filename = $this->FileName;
        return $this->doIsFile( $filename );
    }
1363449
public static function CacheReady($CacheName) {
      if (!array_key_exists($CacheName,self::$Caches))
         return FALSE;
         
      if (!sizeof(self::$Caches[$CacheName]['cache']))
         return FALSE;
         
      return TRUE;
   }
791859
public static function check($filename, array $allowedExtension)
    {
        $ext = pathinfo($filename, PATHINFO_EXTENSION);

        if (empty($ext)) {
            return false;
        }

        return in_array($ext, $allowedExtension);
    }
1126251
public static function clearStatCache($filename = null) {
    if (!empty($filename)) {
      unset(self::$stat_cache[self::getHashValue($filename)]);
    } else {
      self::$stat_cache = [];
    }
  }
747786
private function clientCacheForFile($path)
	{
		$lastModified = filemtime($path);

		if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $lastModified)
		{
			header('HTTP/1.0 304 Not Modified');
			exit;
		}
	}
342324
private boolean checkIfLoaded(String filename) {

        String title;
        if (basefilename.lastIndexOf('.') > 0)
            title = basefilename.substring(0, basefilename.lastIndexOf('.'));
        else
            return false;

        if (filePhotos.containsKey(title))
            return true;

        return false;
    }
1173244
protected function validateCache($fileName)
    {
        $hash = $this->getHash($fileName);
        if (!file_exists($fileName) || !isset($this->cachedFiles[$hash])) {
            return false;
        }
        
        $fileChecksum = md5_file($fileName);
        $cachedChecksum = $this->cachedFiles[$hash]['checksum'];
        
        if ($fileChecksum != $cachedChecksum) {
            return false;
        }
        
        return true;
    }
990388
static public function file($content, $filename = '')
    {
        if (isset(Loader::$callback['CacheFile'])) {
            return call_user_func_array(Loader::$callback['CacheFile'], func_get_args());
        }
        empty($filename) && $filename = md5($content) . '.' . self::getFileExt($content);
        if (self::check() && file_put_contents(self::$cachepath . $filename, $content)) {
            return self::$cachepath . $filename;
        }
        return false;
    }
737343
function isExist(filename) {
    try {
        fs.accessSync(filename, fs.R_OK);
        return true;
    } catch (e) {
        return false;
    }
}
380970
function checkFile(fileName, contents) {
    forbiddenCode.forEach(function(forbiddenItem) {
        if (contents.indexOf(forbiddenItem) > -1) {
            /* eslint-disable */
            console.log('FAILURE: '.red + 'You left a '.reset + forbiddenItem.yellow + ' in '.reset + fileName.cyan);
            /* eslint-enable */
            errorFound = true;
        }
    });
}
276432
public function setFileName($fileName = null) {
		if (empty($fileName)) {
			return false;
		}

		$this->_fileName = (string)$fileName;

		return true;
	}
306239
public function checkForCacheFile()
    {
        // first check if we can create a file
        if (!$this->canCreateCacheFile()) {
            return;
        }
        $cacheEntry = HtmlCacheCache::findOne(['uri' => $this->uri, 'siteId' => $this->siteId]);

        // check if cache exists
        if ($cacheEntry) {
            $file = $this->getCacheFileName($cacheEntry->uid);
            if (file_exists($file)) {
                // load cache - may return false if cache has expired
                if ($this->loadCache($file)) {
                    return \Craft::$app->end();
                }
            }
        }
        // Turn output buffering on
        ob_start();
    }
322182
function stat($filename)
    {
        if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
            return false;
        }

        $filename = $this->_realpath($filename);
        if ($filename === false) {
            return false;
        }

        if ($this->use_stat_cache) {
            $result = $this->_query_stat_cache($filename);
            if (is_array($result) && isset($result['.']) && isset($result['.']->stat)) {
                return $result['.']->stat;
            }
            if (is_object($result) && isset($result->stat)) {
                return $result->stat;
            }
        }

        $stat = $this->_stat($filename, NET_SFTP_STAT);
        if ($stat === false) {
            $this->_remove_from_stat_cache($filename);
            return false;
        }
        if (isset($stat['type'])) {
            if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) {
                $filename.= '/.';
            }
            $this->_update_stat_cache($filename, (object) array('stat' => $stat));
            return $stat;
        }

        $pwd = $this->pwd;
        $stat['type'] = $this->chdir($filename) ?
            NET_SFTP_TYPE_DIRECTORY :
            NET_SFTP_TYPE_REGULAR;
        $this->pwd = $pwd;

        if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) {
            $filename.= '/.';
        }
        $this->_update_stat_cache($filename, (object) array('stat' => $stat));

        return $stat;
    }