NoCache¶
Prevents caching by setting appropriate HTTP headers.
Usage¶
Headers Set¶
Example¶
package main
import (
"github.com/gomarten/marten"
"github.com/gomarten/marten/middleware"
)
func main() {
app := marten.New()
// Apply to specific routes
api := app.Group("/api")
api.Use(middleware.NoCache)
api.GET("/user", func(c *marten.Ctx) error {
return c.OK(marten.M{"user": "data"})
})
app.Run(":8080")
}
Use Cases¶
- API responses that should never be cached
- User-specific data
- Real-time information
- Security-sensitive endpoints