fix(avatar): add default cache max age for avatar response
This commit is contained in:
parent
4b85541d73
commit
db6681f448
1 changed files with 4 additions and 0 deletions
|
@ -76,6 +76,8 @@ type ThemeChose struct {
|
|||
Theme string `json:"theme" binding:"required,hexcolor|rgb|rgba|hsl"`
|
||||
}
|
||||
|
||||
const avatarMaxAge = 3600
|
||||
|
||||
// Update 更新主题设定
|
||||
func (service *ThemeChose) Update(c *gin.Context, user *model.User) serializer.Response {
|
||||
user.OptionsSerialized.PreferredTheme = service.Theme
|
||||
|
@ -194,6 +196,8 @@ func (service *AvatarService) Get(c *gin.Context) serializer.Response {
|
|||
"l": model.GetSettingByName("avatar_size_l"),
|
||||
}
|
||||
|
||||
c.Header("Cache-Control", fmt.Sprintf("max-age=%d", avatarMaxAge))
|
||||
|
||||
// Gravatar 头像重定向
|
||||
if user.Avatar == "gravatar" {
|
||||
server := model.GetSettingByName("gravatar_server")
|
||||
|
|
Loading…
Add table
Reference in a new issue