1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00

Add one more browser (and 304 server) cache method using ETag and If-None-Match headers

And replace the 'ctx.WriteWithExpiration' with simple 'ctx.Write' at 'StaticEmbeddedHandler' of core/router/fs.go, now that we have plenty of options for client cache give the end-dev the oportunity to use them or not on static embedded handlers


Former-commit-id: 9c9e2f3de3c5ad8c9e14e453b67e6b649b02bde8
This commit is contained in:
Gerasimos Maropoulos
2018-03-18 11:55:05 +02:00
parent fae3906587
commit 8e9deec4ab
4 changed files with 72 additions and 4 deletions

View File

@@ -68,7 +68,7 @@ func StaticEmbeddedHandler(vdir string, assetFn func(name string) ([]byte, error
names = append(names, path)
}
modtime := time.Now()
// modtime := time.Now()
h := func(ctx context.Context) {
reqPath := strings.TrimPrefix(ctx.Request().URL.Path, "/"+vdir)
@@ -100,7 +100,7 @@ func StaticEmbeddedHandler(vdir string, assetFn func(name string) ([]byte, error
}
ctx.ContentType(cType)
if _, err := ctx.WriteWithExpiration(buf, modtime); err != nil {
if _, err := ctx.Write(buf); err != nil {
ctx.StatusCode(http.StatusInternalServerError)
ctx.StopExecution()
}