mirror of
https://github.com/kataras/iris.git
synced 2026-01-09 21:15:56 +00:00
Complete the HISTORY.md for the new v7.2.0
Former-commit-id: 0f2fe05ee0dd7239711284a241557282c8a740a4
This commit is contained in:
@@ -32,6 +32,13 @@ The amount of the next two or three donations you'll send they will be immediate
|
|||||||
|
|
||||||
# Th, 15 June 2017 | v7.2.0
|
# Th, 15 June 2017 | v7.2.0
|
||||||
|
|
||||||
|
### Cache
|
||||||
|
|
||||||
|
Declare the `iris.Cache alias` to the new, improved and most-suited for common usage, `cache.Handler function`.
|
||||||
|
|
||||||
|
`iris.Cache` be used as middleware in the chain now, example [here](_examples/intermediate/cache-markdown/main.go). However [you can still use the cache as a wrapper](cache/cache_test.go) by importing the `github.com/kataras/iris/cache` package.
|
||||||
|
|
||||||
|
|
||||||
### File server
|
### File server
|
||||||
|
|
||||||
- **Fix** [that](https://github.com/iris-contrib/community-board/issues/12).
|
- **Fix** [that](https://github.com/iris-contrib/community-board/issues/12).
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/kataras/iris"
|
"github.com/kataras/iris"
|
||||||
"github.com/kataras/iris/cache"
|
|
||||||
"github.com/kataras/iris/context"
|
"github.com/kataras/iris/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -59,12 +58,7 @@ All features of Sundown are supported, including:
|
|||||||
func main() {
|
func main() {
|
||||||
app := iris.New()
|
app := iris.New()
|
||||||
|
|
||||||
// first argument is the handler which response's we want to apply the cache.
|
app.Get("/", iris.Cache(10*time.Second), writeMarkdown)
|
||||||
// if second argument, expiration, is <=time.Second then the cache tries to set the expiration from the "cache-control" maxage header's value(in seconds)
|
|
||||||
// and if that header is empty or not exist then it sets a default of 5 minutes.
|
|
||||||
writeMarkdownCached := cache.Cache(writeMarkdown, 10*time.Second) // or CacheHandler to get the handler
|
|
||||||
|
|
||||||
app.Get("/", writeMarkdownCached.ServeHTTP)
|
|
||||||
// saves its content on the first request and serves it instead of re-calculating the content.
|
// saves its content on the first request and serves it instead of re-calculating the content.
|
||||||
// After 10 seconds it will be cleared and resetted.
|
// After 10 seconds it will be cleared and resetted.
|
||||||
|
|
||||||
@@ -78,29 +72,3 @@ func writeMarkdown(ctx context.Context) {
|
|||||||
|
|
||||||
ctx.Markdown(markdownContents)
|
ctx.Markdown(markdownContents)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notes:
|
|
||||||
// Cached handler is not changing your pre-defined headers,
|
|
||||||
// so it will not send any additional headers to the client.
|
|
||||||
// The cache happening at the server-side's memory.
|
|
||||||
//
|
|
||||||
// see "DefaultRuleSet" in "cache/client/ruleset.go" to see how you can add separated
|
|
||||||
// rules to each of the cached handlers (`.AddRule`) with the help of "/cache/client/rule"'s definitions.
|
|
||||||
//
|
|
||||||
// The default rules are:
|
|
||||||
/*
|
|
||||||
// #1 A shared cache MUST NOT use a cached response to a request with an
|
|
||||||
// Authorization header field
|
|
||||||
rule.HeaderClaim(ruleset.AuthorizationRule),
|
|
||||||
// #2 "must-revalidate" and/or
|
|
||||||
// "s-maxage" response directives are not allowed to be served stale
|
|
||||||
// (Section 4.2.4) by shared caches. In particular, a response with
|
|
||||||
// either "max-age=0, must-revalidate" or "s-maxage=0" cannot be used to
|
|
||||||
// satisfy a subsequent request without revalidating it on the origin
|
|
||||||
// server.
|
|
||||||
rule.HeaderClaim(ruleset.MustRevalidateRule),
|
|
||||||
rule.HeaderClaim(ruleset.ZeroMaxAgeRule),
|
|
||||||
// #3 custom No-Cache header used inside this library
|
|
||||||
// for BOTH request and response (after get-cache action)
|
|
||||||
rule.Header(ruleset.NoCacheRule, ruleset.NoCacheRule)
|
|
||||||
*/
|
|
||||||
|
|||||||
Reference in New Issue
Block a user