我有主站点(site.com)和我的资源(css、images、js)所在的站点(somecdn.com)。我想在登录之前推送一些这些资源。我发送 ajax 请求并在响应头中设置 Link-s 与资源。但是我的资源下载等待并且没有任何推送(见附图)。如何为 somecdn.com 中的资源启用 http2 推送? 有推 无推
我在 docker 中创建了两个站点:site.com 和 somecdn.com 并检查 http2 push 是否在这两个站点上正常工作(并且分别按预期工作)。
https://127.0.0.1:8081/index.php
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>IndexPHP</h1></iframe>-->
<script>
window.onload = function () {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://127.0.0.1:8083/push.php', true);
xhr.send();
}
</script>
</body>
</html>
https://127.0.0.1:8083/push.php
<?php
header("Link: </style.css>; rel=preload; as=style", false);
header("Link: </image.png>; rel=preload; as=image", false);
我希望无需等待即可在 Chrome 开发工具资源中看到“推送”指示。
喵喵时光机