~~~
// Package main shows how you can use the `WriteWithExpiration`
// based on the "modtime", if it's newer than the request header then
// it will refresh the contents, otherwise will let the client (99.9% the browser)
// to handle the cache mechanism, it's faster than iris.Cache because server-side
// has nothing to do and no need to store the responses in the memory.
package main
import (
"time"
"github.com/kataras/iris"
)
const refreshEvery = 10 * time.Second
func main() {
app := iris.New()
app.Use(iris.Cache304(refreshEvery))
// same as:
// app.Use(func(ctx iris.Context) {
// now := time.Now()
// if modified, err := ctx.CheckIfModifiedSince(now.Add(-refresh)); !modified && err == nil {
// ctx.WriteNotModified()
// return
// }
// ctx.SetLastModified(now)
// ctx.Next()
// })
app.Get("/", greet)
app.Run(iris.Addr(":8080"))
}
func greet(ctx iris.Context) {
ctx.Header("X-Custom", "my custom header")
ctx.Writef("Hello World! %s", time.Now())
}
~~~
- api文档
- yaag
- 认证
- 认证基本
- oauth2
- 缓存
- 客户端
- 简单的
- 配置
- 配置文件
- tml文件
- yaml文件
- 功能
- 处理程序
- Negroni Like
- http
- Real Usecase Raven
- cookies
- Basic
- 安全cookie
- 实验程序
- casbin
- 云监视
- cors
- csrf
- jwt
- 新文学
- Casbin
- 文件服务器
- Hero
- http监听
- http请求
- HTTP Responsewriter
- Miscellaneous
- MVC
- mvc概观
- 中间件
- Hello World
- 登陆
- Session 控制器
- Singleton
- MVC基本
- ORM
- xorm
- 概况
- 路由
- 概观
- 自定义上下文
- 自定义包装
- 动态路径
- 相反
- HTTP错误
- 路由状态
- 路由基本
- Sessions
- 构建
- 子域
- 重定向
- 万维网
- Single
- 通配符
- 多域名
- 测试
- 教程
- 视图
- Template Html 0
- Template Html 1
- Template Html 2
- Template Html 3
- Template Html 4
- Webassembly
- Websocket
