Skip to content

A distributed HTTP cache module for Hertz based on Souin HTTP cache.

License

Notifications You must be signed in to change notification settings

hertz-contrib/httpcache

Repository files navigation

Hertz middleware: HTTP cache

This is a distributed HTTP cache module for Hertz based on Souin HTTP cache.

Features

Example

There is the example about the HTTP cache initialization.

import (
	"context"
	"net/http"

	// ...
	httpcache "github.com/hertz-contrib/httpcache/server"
)

func main() {
	// ...
	h.Use(httpcache.NewHTTPCache(httpcache.DevDefaultConfiguration))
	// ...
}

With that your application will be able to cache the responses if possible and returns at least the Cache-Status HTTP header with the different directives mentioned in the RFC specification.
You have to pass a Hertz Configuration structure into the NewHTTPCache method (you can use the DefaultConfiguration variable to have a built-in production ready configuration).
See the full detailed configuration names here.

Other resources

See the Souin configuration for the full configuration, and its associated development hertz middleware

About

A distributed HTTP cache module for Hertz based on Souin HTTP cache.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published