1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 11:57:02 +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

@@ -2177,6 +2177,8 @@ const (
IfModifiedSinceHeaderKey = "If-Modified-Since"
// CacheControlHeaderKey is the header key of "Cache-Control".
CacheControlHeaderKey = "Cache-Control"
// ETagHeaderKey is the header key of "ETag".
ETagHeaderKey = "ETag"
// ContentDispositionHeaderKey is the header key of "Content-Disposition".
ContentDispositionHeaderKey = "Content-Disposition"
@@ -2282,7 +2284,7 @@ func (ctx *context) WriteNotModified() {
h := ctx.ResponseWriter().Header()
delete(h, ContentTypeHeaderKey)
delete(h, ContentLengthHeaderKey)
if h.Get("Etag") != "" {
if h.Get(ETagHeaderKey) != "" {
delete(h, LastModifiedHeaderKey)
}
ctx.StatusCode(http.StatusNotModified)