I'm trying to get a simple http/2 server push demo to work with the following simple hello world example:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Http 2 push demo</title>
<link rel="preload" href="core.css" as="style">
</head>
<body>
Hello World!
</body>
</html>
core.css
body {
font-size: larger;
font-weight: bold;
color: red;
}
In Chrome 66.0.x the css seems to be loaded successfully but I keep getting the following warning:
The resource http://localhost:8080/core.css was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it Please make sure it has an appropriate
as
value and it is preloaded intentionally.
and the css is not applied to the html body.
Am I missing something? Any ideas?
Right now you are only pre-loading the resource, but you are not using it in any way afterwards.
You still need a “normal” <link rel="styesheet" href="core.css">
to actually embed this stylesheet into the document and get it applied.