我在 Safari 中遇到了一个问题,即在我们的 Apache 2.4 服务器上通过 http/2 加载的网站会间歇性地(每 3-5 个请求)无法加载某些资源。页面似乎总是可以加载,但 JS、CSS 和图像似乎会失败。我会Failed to load resource: The network connection was lost.
在控制台中看到错误,偶尔也会看到Unexpected end of script
错误。如果我直接加载 JS,每 3-5 个请求只有大约 3/5 的文件会加载,并且不会抛出任何错误。如果我禁用 http/2,一切都会按预期运行。所有网站都使用 Let's Encrypt 证书运行。
这个问题有解决办法吗?作为替代方案,是否可以使用 BrowserMatch 仅对 Safari 禁用 http2?虽然这不是理想的解决方案,但总比网站无法在 Safari 中加载一半资源要好。不过,我以前从未使用过 BrowserMatch,而且我不确定语法是什么。
配置信息:
Debian version: 9.6
Server version: Apache/2.4.25 (Debian)
Server built: 2018-11-03T18:46:19
Protocols h2 h2c http/1.1
PHP7.0 and PHP7.2 running with FPM
已加载模块:
core_module (static)
so_module (static)
watchdog_module (static)
http_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
unixd_module (static)
access_compat_module (shared)
actions_module (shared)
alias_module (shared)
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
expires_module (shared)
filter_module (shared)
http2_module (shared)
mime_module (shared)
mpm_event_module (shared)
negotiation_module (shared)
proxy_module (shared)
proxy_fcgi_module (shared)
reqtimeout_module (shared)
rewrite_module (shared)
setenvif_module (shared)
socache_shmcb_module (shared)
ssl_module (shared)
status_module (shared)
vhost_alias_module (shared)
网络请求失败的示例:
Summary
URL: https://www.example.com/wp-content/themes/example/app/scripts.min.js
Status: 200
Source: Network
Address: 111.111.111.111:443
Request
:method: GET
:scheme: https
:authority: www.example.com
:path: /wp-content/themes/example/app/scripts.min.js
Cookie: _ga=GA1.2.693564551.1543614967; _gid=GA1.2.1931614765.1543937949; _gat_gtag_UA_127993364_1=1
Accept: */*
Cache-Control: max-age=0
Accept-Language: en-us
If-None-Match: "45da3-57c343a615009-gzip"
Host: www.tahv.org
If-Modified-Since: Tue, 04 Dec 2018 15:50:43 GMT
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15
Referer: https://www.example.com/
Accept-Encoding: br, gzip, deflate
Connection: keep-alive
Response
:status: 200
Content-Type: application/javascript
Expires: Fri, 07 Dec 2018 16:31:14 GMT
Last-Modified: Tue, 04 Dec 2018 15:50:43 GMT
Vary: Accept-Encoding
Accept-Ranges: bytes
Date: Tue, 04 Dec 2018 16:31:14 GMT
Content-Encoding: gzip
Cache-Control: max-age=259200
ETag: "45da3-57c343a615009-gzip"
Server: Apache/2.4.25 (Debian)