diff --git a/main.go b/main.go index 9e40971..28989d9 100644 --- a/main.go +++ b/main.go @@ -21,13 +21,14 @@ import ( const ( // backgroundImageFilename = "images/bg.png" - radius = 0 - fontSize = 12 - textMarginX = 5.0 - textMarginY = -2.0 - badgeWidth = 180 - badgeHeight = 20 - textStyle = "text-anchor:right;font-size:12px;fill:white;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;" + radius = 0 + fontSize = 12 + textMarginX = 5.0 + textMarginY = -2.0 + badgeWidth = 180 + badgeHeight = 20 + textStyle = "text-anchor:right;font-size:12px;fill:white;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;" + badgeExpireSeconds = 120 ) var ( @@ -94,6 +95,7 @@ func geneateSvg(client api.Client, c *gin.Context) error { w := c.Writer w.Header().Set("Content-Type", "image/svg+xml") + w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%d, s-maxage=%d", badgeExpireSeconds, badgeExpireSeconds)) canvas := svg.New(w) canvas.Start(badgeWidth, badgeHeight) canvas.Rect(0, 0, badgeWidth, badgeHeight, "fill-opacity:1.00; fill:rgb(90,90,90)") @@ -157,6 +159,7 @@ func generateBadge(client api.Client, c *gin.Context) error { w := c.Writer c.Status(http.StatusOK) w.Header().Set("Content-Type", "image/png") + w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%d, s-maxage=%d", badgeExpireSeconds, badgeExpireSeconds)) return dc.EncodePNG(w) }