【问题标题】:Can I send resources with HTTP/2 Server Push?我可以使用 HTTP/2 Server Push 发送资源吗?
【发布时间】:2019-02-22 07:36:48
【问题描述】:
我的 Web 应用程序是用 Go 编写的,部署在 Google App Engine Standard 上,具有为每个页面生成 HTML 的处理程序(服务器端呈现)。如果我可以在某些情况下(谨慎地)使用HTTP/2 Server Push 抢先发送 CSS 和 JS 资源以及 HTML 响应,那对性能会很好。
App Engine 的 Go 运行时是否可以实现?
(另一种说法:App Engine 中的 ResponseWriter 是否实现了http.Pusher 接口?)
【问题讨论】:
标签:
http2
google-app-engine-go
【解决方案1】:
现在这似乎不可能开箱即用:
if _, ok := w.(http.Pusher); ok {
fmt.Fprintln(w, "This ResponseWriter is a Pusher :)")
} else {
fmt.Fprintln(w, "This ResponseWriter is NOT a Pusher :(")
}
生产
This ResponseWriter is NOT a Pusher :(
(在生产中,以及在本地开发服务器中)