From 3dceccfde20b4bbfbf1dcc14c0a5a7957dcc1274 Mon Sep 17 00:00:00 2001 From: qydysky Date: Tue, 8 Jun 2021 16:59:42 +0800 Subject: [PATCH] =?utf8?q?=E5=8F=8D=E9=A6=88=E6=9B=B4=E5=A4=9A=E4=BF=A1?= =?utf8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/F.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Reply/F.go b/Reply/F.go index b8947fa..60515ad 100644 --- a/Reply/F.go +++ b/Reply/F.go @@ -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) -- 2.39.2