Open longbigbronzeelephantfish opened 7 years ago
Same problem here. That line is causing my style to be downloaded twice, once with my website url, and the second with my CDN url
this works for both CDN and CloudFlare
/**
* Sends HTTP/2 push header
*/
public function http2_header_add( $url, $as ) {
if ( empty( $url ) )
return;
$domain = '';
// Cloudflare needs URI without host
$uri = Util_Environment::url_to_uri( $url );
// CDN always require domain
if( $this->config->get_boolean( 'cdn.enabled' ) ){
$domain = Dispatcher::component( 'Cdn_Core' )->get_cdn()->get_prepend_path($uri);
}
header( 'Link: <' . $domain . $uri . '>; rel=preload; as=' . $as, false );
}
Configuration: Generic Mirror used for CDN HTTP/2 push enabled for CSS and JS
The generated headers instructs the browser to preload the resources from the website:
The browser ends up preloading the resources but not using them
Editing Minify_Plugin.php from
to
fixes the problem, but will probably break CloudFlare functionality.
The headers are correct now: