diff --git a/config/config.go b/config/config.go index 9549cab..8efde9e 100644 --- a/config/config.go +++ b/config/config.go @@ -50,7 +50,7 @@ func NewConfig() *Config { proxyConfig := middleware.ProxyConfig{ Skipper: middleware.DefaultSkipper, ContextKey: "target", - RetryCount: 0, + RetryCount: len(configFile.TezosHost) + 1, Balancer: balancer, RetryFilter: func(c echo.Context, err error) bool { if httpErr, ok := err.(*echo.HTTPError); ok { diff --git a/middlewares/cache.go b/middlewares/cache.go index 5c0727b..a0eee15 100644 --- a/middlewares/cache.go +++ b/middlewares/cache.go @@ -14,7 +14,10 @@ func Cache(config *config.Config) echo.MiddlewareFunc { return echocache.New(&echocache.Config{ TTL: config.CacheTTL, Cache: func(r *http.Request) bool { - if !config.ConfigFile.Cache.Enabled || r.Method != http.MethodGet { + if !config.ConfigFile.Cache.Enabled || + r.Method != http.MethodGet || + strings.Contains(r.URL.Path, "mempool") || + strings.Contains(r.URL.Path, "monitor") { return false } diff --git a/middlewares/retry.go b/middlewares/retry.go index e770e75..f9bc9f0 100644 --- a/middlewares/retry.go +++ b/middlewares/retry.go @@ -3,6 +3,7 @@ package middlewares import ( "bytes" "net/http" + "strings" "github.com/labstack/echo/v4" "github.com/marigold-dev/tzproxy/config" @@ -11,7 +12,10 @@ import ( func Retry(config *config.Config) echo.MiddlewareFunc { return func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) (err error) { - if config.ConfigFile.TezosHostRetry == "" { + if config.ConfigFile.TezosHostRetry == "" || + c.Request().Method != http.MethodGet || + strings.Contains(c.Request().URL.Path, "mempool") || + strings.Contains(c.Request().URL.Path, "monitor") { return next(c) }