304 not modified
in order to let the browser or any compatible client to handle the caching by itself.iris.Cache
and iris.Cache304
middlewares.Cache
is a middleware that provides server-side cache functionality to the next handlers, can be used as: app.Get("/", iris.Cache, aboutHandler)
.Cache
accepts one single parameter: the cache expiration duration. If the expiration is invalid value, <=2 seconds, then expiration is taken by the "cache-control's maxage" headerCache304
for an alternative approach that may be more suited to your needs.NoCache
is a middleware which overrides the Cache-Control, Pragma and Expires headers in order to disable the cache during the browser's back and forward feature.StaticCache
for the opposite behavior.StaticCache
returns a middleware for caching static files by sending the "Cache-Control" and "Expires" headers to the client. It accepts a single input parameter, the "cacheDur", a time.Duration that it's used to calculate the expiration.NoCache
middleware instaed to disable the caching between browser's "back" and "forward" actions.app.Use(iris.StaticCache(24 * time.Hour))
or app.Use(iris.StaticCache(-1))
.Cache304
returns a middleware sends a StatusNotModified
(304) whenever the "If-Modified-Since" request header (time) is before the time.Now() + expiresEvery (always compared to their UTC values).ctx.WriteWithExpiration
with a "modtime" based on the file modified date, similar to the HandleDir
(which sends status OK(200) and browser disk caching instead of 304).