public function functionPreload(string $link, array $parameters = []): string
    {
        $push = !(!empty($parameters['nopush']) && $parameters['nopush'] == true);

        if (!$push || !in_array(md5($link), $this->h2pushCache)) {
            $header = sprintf('Link: <%s>; rel=preload', $link);

            // as
            if (!empty($parameters['as'])) {
                $header = sprintf('%s; as=%s', $header, $parameters['as']);
            }
            // type
            if (!empty($parameters['type'])) {
                $header = sprintf('%s; type=%s', $header, $parameters['as']);
            }
            // crossorigin
            if (!empty($parameters['crossorigin']) && $parameters['crossorigin'] == true) {
                $header .= '; crossorigin';
            }
            // nopush
            if (!$push) {
                $header .= '; nopush';
            }

            header($header, false);

            // Cache
            if ($push) {
                $this->h2pushCache[] = md5($link);
                setcookie(sprintf('%s[%s]', self::H2PUSH_CACHE_COOKIE, md5($link)), 1, 0, '/', '', false, true);
            }
        }

        return $link;
    }
public function functionPreload(string $link, array $parameters = []): string
    {
        $push = !(!empty($parameters['nopush']) && $parameters['nopush'] == true);

        if (!$push || !in_array(md5($link), $this->h2pushCache)) {
            $header = sprintf('Link: <%s>; rel=preload', $link);

            // as
            if (!empty($parameters['as'])) {
                $header = sprintf('%s; as=%s', $header, $parameters['as']);
            }
            // type
            if (!empty($parameters['type'])) {
                $header = sprintf('%s; type=%s', $header, $parameters['as']);
            }
            // crossorigin
            if (!empty($parameters['crossorigin']) && $parameters['crossorigin'] == true) {
                $header .= '; crossorigin';
            }
            // nopush
            if (!$push) {
                $header .= '; nopush';
            }

            header($header, false);

            // Cache
            if ($push) {
                $this->h2pushCache[] = md5($link);
                setcookie(sprintf('%s[%s]', self::H2PUSH_CACHE_COOKIE, md5($link)), 1, 0, '/', '', false, true);
            }
        }

        return $link;
    }
public function functionPreload ( string $ link , array $ parameters = [ ] ) : string { $ push = ! ( ! empty ( $ parameters [ 'nopush' ] ) && $ parameters [ 'nopush' ] == true ) ; if ( ! $ push || ! in_array ( md5 ( $ link ) , $ this -> h2pushCache ) ) { $ header = sprintf ( 'Link: <%s>; rel=preload' , $ link ) ; // as if ( ! empty ( $ parameters [ 'as' ] ) ) { $ header = sprintf ( '%s; as=%s' , $ header , $ parameters [ 'as' ] ) ; } // type if ( ! empty ( $ parameters [ 'type' ] ) ) { $ header = sprintf ( '%s; type=%s' , $ header , $ parameters [ 'as' ] ) ; } // crossorigin if ( ! empty ( $ parameters [ 'crossorigin' ] ) && $ parameters [ 'crossorigin' ] == true ) { $ header .= '; crossorigin' ; } // nopush if ( ! $ push ) { $ header .= '; nopush' ; } header ( $ header , false ) ; // Cache if ( $ push ) { $ this -> h2pushCache [ ] = md5 ( $ link ) ; setcookie ( sprintf ( '%s[%s]' , self :: H2PUSH_CACHE_COOKIE , md5 ( $ link ) ) , 1 , 0 , '/' , '' , false , true ) ; } } return $ link ; }
Function preload to pre loading of request for HTTP 2 protocol.

@param string $link
@param array  $parameters

@return string Link
Function preload to pre loading of request for HTTP 2 protocol .