Add caching for static web assets
This commit is contained in:
@@ -20,6 +20,7 @@ type HTTP struct {
|
||||
Addr string
|
||||
Namespace string
|
||||
Root string
|
||||
CacheTTL int
|
||||
}
|
||||
|
||||
// GRPC defines the available grpc configuration.
|
||||
|
||||
@@ -136,6 +136,13 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
|
||||
EnvVars: []string{"SETTINGS_HTTP_ROOT"},
|
||||
Destination: &cfg.HTTP.Root,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "http-cache-ttl",
|
||||
Value: 604800, // 7 days
|
||||
Usage: "Set the static assets caching duration in seconds",
|
||||
EnvVars: []string{"SETTINGS_CACHE_TTL"},
|
||||
Destination: &cfg.HTTP.CacheTTL,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "grpc-addr",
|
||||
Value: "0.0.0.0:9191",
|
||||
|
||||
@@ -60,6 +60,7 @@ func Server(opts ...Option) http.Service {
|
||||
assets.Logger(options.Logger),
|
||||
assets.Config(options.Config),
|
||||
),
|
||||
options.Config.HTTP.CacheTTL,
|
||||
))
|
||||
|
||||
mux.Route(options.Config.HTTP.Root, func(r chi.Router) {
|
||||
|
||||
Reference in New Issue
Block a user