详见:Introducing HTTP/2 Server Push with NGINX 1.13.9
server {
# Ensure that HTTP/2 is enabled for the server
listen 443 ssl http2;
ssl_certificate ssl/certificate.pem;
ssl_certificate_key ssl/key.pem;
root /var/www/html;
# whenever a client requests demo.html, also push
# /style.css, /image1.jpg and /image2.jpg
location = /demo.html {
http2_push /style.css;
http2_push /image1.jpg;
http2_push /image2.jpg;
}
}
1
cdkey51 2018-02-22 08:12:06 +08:00 via iPhone
支持一下 学习了
|
2
carlhan 2018-02-22 10:02:00 +08:00 via iPhone
如果是用 webpack 打包出来的带 bundle hash 的 assets 要如何配置呢
|
3
Servo OP @carlhan 简单点就手动添加后面的 hash,我试过是可行的,缺点是一修改资源就得修改 Nginx 配置。最好是使用内文中说的“ http2_push_preload ”,给资源 添加“ rel=preload ”标记。
|
4
RobertYang 2018-02-22 11:59:16 +08:00 via Android
昨晚已使用上了
|