]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
反馈更多信息
authorqydysky <qydysky@foxmail.com>
Tue, 8 Jun 2021 08:59:42 +0000 (16:59 +0800)
committerqydysky <qydysky@foxmail.com>
Tue, 8 Jun 2021 08:59:42 +0000 (16:59 +0800)
Reply/F.go

index b8947fafaadfb6b5998b51e11985cceb45464fae..60515ad39a72fc261f9e2b4c9af15ad03f497dde 100644 (file)
@@ -2039,8 +2039,8 @@ func init() {
                                                                return
                                                        }
 
-                                                       //PROCESS-TIME
-                                                       w.Header().Set("PROCESS-TIME", time.Since(start).String())
+                                                       //Server-Timing
+                                                       w.Header().Set("Server-Timing", fmt.Sprintf("dur=%d", time.Since(start).Microseconds()))
 
                                                        if _,err := w.Write(res);err != nil {
                                                                flog.L(`E: `,err)
@@ -2049,11 +2049,14 @@ func init() {
                                                }
                                        } else if filepath.Ext(path) == `.m4s` {
                                                w.Header().Set("Server", "live")
-                                               w.Header().Set("Cache-Control", "max-age=60")
+                                               w.Header().Set("Cache-Control", "Cache-Control:public, max-age=3600")
 
                                                path = base_dir+path
 
-                                               var buf []byte
+                                               var (
+                                                       buf []byte
+                                                       cached bool
+                                               )
 
                                                if b,ok := m4s_cache.Load(path);!ok{
                                                        f,err := os.OpenFile(path,os.O_RDONLY,0644)
@@ -2083,6 +2086,7 @@ func init() {
                                                                }()
                                                        }
                                                } else {
+                                                       cached = true
                                                        buf,_ = b.([]byte)
                                                }
 
@@ -2093,8 +2097,8 @@ func init() {
                                                        return
                                                }
 
-                                               //PROCESS-TIME
-                                               w.Header().Set("PROCESS-TIME", time.Since(start).String())
+                                               //Server-Timing
+                                               w.Header().Add("Server-Timing", fmt.Sprintf("cache=%v;dur=%d", cached, time.Since(start).Microseconds()))
                                                w.WriteHeader(http.StatusOK)
                                                if _,err := w.Write(buf);err != nil {
                                                        flog.L(`E: `,err)