【问题标题】: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 :(
    

    (在生产中,以及在本地开发服务器中)

    【讨论】:

      猜你喜欢
      • 2020-04-26
      • 2017-03-04
      • 2017-10-05
      • 2015-12-06
      • 2016-03-30
      • 2013-04-03
      • 2020-04-23
      • 1970-01-01
      • 2023-03-06
      相关资源
      最近更新 更多