gpt4 book ai didi

http - 可以在 header 中指定异步文件吗?

转载 作者:可可西里 更新时间:2023-11-01 15:11:26 25 4
gpt4 key购买 nike

所以我的时间线总是这样

http://see.kirkstrobeck.com/TjQU/Screen%20Shot%202014-02-04%20at%206.40.14%20PM.png

index.html 加载然后请求其他文件。我在想有没有办法让响应请求的 header 说明应该下载哪些文件?所以它看起来像这样..

http://see.kirkstrobeck.com/TjKl/Screen%20Shot%202014-02-04%20at%206.40.14%20PM.png

也许像..

<?

header('fileGetRequest: /js/common.js');
header('fileGetRequest: /css/common.css');

?>

最佳答案

我今天不知道这样做的方法,但是 SPDY使用 rel=subresource 扩展 Link header ,正是为了这个用途。

来自 Server Push and Server Hints :

Server Hint is a mechanism where the server can notify the client of a resource that will be needed before the client can discover it. The server does not send the entire contents of the resource, but rather just the URL as an early part of a response. The client can then validate its cache (potentially even eliminating the need for a GET-if-modified-since), and will formally request the resource only if needed.

HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Encoding: gzip
Content-Length: 13847
Content-Type: text/html; charset=UTF-8
Date: Thu, 13 Jan 2011 17:47:12 GMT
Expires: -1
Server: FastServer1.0
Link: <logic.js>; rel=subresource

<html>
<body>
[ lots of content here ]
<script src="logic.js" type="text/javascript></script>
</body>

示例来源:SPDY - LINK rel=subresource

如果您知道客户端缓存中没有资源,您可能还需要考虑Server Push ,这节省了往返行程。

Server Push is where the server pushes a resource directly to the client without the client asking for the resource. The server is making an assumption here that pushing the resource is desirable. Pushing a cacheable resource can be risky, as the browser might already have the resource and the push can be redundant.


2015 年 5 月编辑

HTTP/2 (基于 SPDY,有点被淘汰)也有 Push Requests (以及 Link header )。

关于http - 可以在 header 中指定异步文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21567694/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com