Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions disperser/dataapi/v2/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,6 @@ func (s *ServerV2) FetchAccountBlobFeed(c *gin.Context) {

s.metrics.IncrementSuccessfulRequestNum("FetchAccountBlobFeed")
s.metrics.ObserveLatency("FetchAccountBlobFeed", time.Since(handlerStart))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxBlobFeedAge))
c.JSON(http.StatusOK, response)
}
3 changes: 2 additions & 1 deletion disperser/dataapi/v2/batches.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func (s *ServerV2) FetchBatchFeed(c *gin.Context) {

s.metrics.IncrementSuccessfulRequestNum("FetchBatchFeed")
s.metrics.ObserveLatency("FetchBatchFeed", time.Since(handlerStart))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxBatchFeedAge))
c.JSON(http.StatusOK, response)
}

Expand Down Expand Up @@ -234,6 +235,6 @@ func (s *ServerV2) FetchBatch(c *gin.Context) {
}
s.metrics.IncrementSuccessfulRequestNum("FetchBatch")
s.metrics.ObserveLatency("FetchBatch", time.Since(handlerStart))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxFeedBlobAge))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxBatchDataAge))
c.JSON(http.StatusOK, batchResponse)
}
8 changes: 4 additions & 4 deletions disperser/dataapi/v2/blobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (s *ServerV2) FetchBlob(c *gin.Context) {
}
s.metrics.IncrementSuccessfulRequestNum("FetchBlob")
s.metrics.ObserveLatency("FetchBlob", time.Since(handlerStart))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxFeedBlobAge))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxBlobDataAge))
c.JSON(http.StatusOK, response)
}

Expand Down Expand Up @@ -253,7 +253,7 @@ func (s *ServerV2) FetchBlobCertificate(c *gin.Context) {
}
s.metrics.IncrementSuccessfulRequestNum("FetchBlobCertificate")
s.metrics.ObserveLatency("FetchBlobCertificate", time.Since(handlerStart))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxFeedBlobAge))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxBlobDataAge))
c.JSON(http.StatusOK, response)
}

Expand Down Expand Up @@ -294,7 +294,7 @@ func (s *ServerV2) FetchBlobAttestationInfo(c *gin.Context) {

s.metrics.IncrementSuccessfulRequestNum("FetchBlobAttestationInfo")
s.metrics.ObserveLatency("FetchBlobAttestationInfo", time.Since(handlerStart))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxFeedBlobAge))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxBlobDataAge))
c.JSON(http.StatusOK, response)
}

Expand Down Expand Up @@ -452,7 +452,7 @@ func (s *ServerV2) sendBlobFeedResponse(
Blobs: blobInfo,
Cursor: cursorStr,
}
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxFeedBlobAge))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxBlobFeedAge))
s.metrics.IncrementSuccessfulRequestNum("FetchBlobFeed")
s.metrics.ObserveLatency("FetchBlobFeed", time.Since(handlerStart))
c.JSON(http.StatusOK, response)
Expand Down
4 changes: 3 additions & 1 deletion disperser/dataapi/v2/operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func (s *ServerV2) FetchOperatorDispersalFeed(c *gin.Context) {

s.metrics.IncrementSuccessfulRequestNum("FetchOperatorDispersalFeed")
s.metrics.ObserveLatency("FetchOperatorDispersalFeed", time.Since(handlerStart))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxDispersalFeedAge))
c.JSON(http.StatusOK, response)
}

Expand Down Expand Up @@ -232,6 +233,7 @@ func (s *ServerV2) FetchOperatorSigningInfo(c *gin.Context) {

s.metrics.IncrementSuccessfulRequestNum("FetchOperatorSigningInfo")
s.metrics.ObserveLatency("FetchOperatorSigningInfo", time.Since(handlerStart))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxSigningInfoAge))
c.JSON(http.StatusOK, response)
}

Expand Down Expand Up @@ -374,7 +376,7 @@ func (s *ServerV2) FetchOperatorDispersalResponse(c *gin.Context) {
}
s.metrics.IncrementSuccessfulRequestNum("FetchOperatorDispersalResponse")
s.metrics.ObserveLatency("FetchOperatorDispersalResponse", time.Since(handlerStart))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxOperatorResponseAge))
c.Writer.Header().Set(cacheControlParam, fmt.Sprintf("max-age=%d", maxOperatorDispersalResponseAge))
c.JSON(http.StatusOK, response)
}

Expand Down
25 changes: 18 additions & 7 deletions disperser/dataapi/v2/server_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,24 @@ const (
// Cache ~1h worth of batches for KV lookups
maxNumKVBatchesToCache = 3600

cacheControlParam = "Cache-Control"
maxFeedBlobAge = 300 // this is completely static
maxOperatorsStakeAge = 300 // not expect the stake change to happen frequently
maxOperatorResponseAge = 300 // this is completely static
maxOperatorPortCheckAge = 60
maxMetricAge = 10
maxThroughputAge = 10
cacheControlParam = "Cache-Control"

// Static content
maxBlobDataAge = 300
maxBatchDataAge = 300
maxOperatorDispersalResponseAge = 300

// Rarely changing content
maxOperatorsStakeAge = 300 // not expect the stake changes frequently
maxOperatorPortCheckAge = 60 // not expect validator port changes frequently, but it's consequential to have right port

// Live content
maxMetricAge = 5
maxThroughputAge = 5
maxBlobFeedAge = 5
maxBatchFeedAge = 5
maxDispersalFeedAge = 5
maxSigningInfoAge = 5
)

type (
Expand Down
Loading