aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorMorgan Bazalgette <git@howl.moe>2018-02-03 23:37:05 +0100
committerLauris BH <lauris@nix.lv>2018-02-04 00:37:05 +0200
commit17655cdf1b409521262d5d54eb19884d307c47ce (patch)
treeb06d15367afc6bd4f915c0e8b9272241bb3f4a3c /routers
parent77f8bad2fb7a6a4ab57b398cb89e6889f76ffe8a (diff)
downloadgitea-17655cdf1b409521262d5d54eb19884d307c47ce.tar.gz
gitea-17655cdf1b409521262d5d54eb19884d307c47ce.zip
Enable caching on assets and avatars (#3376)
* Enable caching on assets and avatars Fixes #3323 * Only set avatar in user BeforeUpdate when there is no avatar set * add error checking after stat * gofmt * Change cache time for avatars to an hour
Diffstat (limited to 'routers')
-rw-r--r--routers/routes/routes.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/routers/routes/routes.go b/routers/routes/routes.go
index e51bfb946a..1d95bb4c76 100644
--- a/routers/routes/routes.go
+++ b/routers/routes/routes.go
@@ -7,6 +7,7 @@ package routes
import (
"os"
"path"
+ "time"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/auth"
@@ -53,21 +54,23 @@ func NewMacaron() *macaron.Macaron {
}
m.Use(public.Custom(
&public.Options{
- SkipLogging: setting.DisableRouterLog,
+ SkipLogging: setting.DisableRouterLog,
+ ExpiresAfter: time.Hour * 6,
},
))
m.Use(public.Static(
&public.Options{
- Directory: path.Join(setting.StaticRootPath, "public"),
- SkipLogging: setting.DisableRouterLog,
+ Directory: path.Join(setting.StaticRootPath, "public"),
+ SkipLogging: setting.DisableRouterLog,
+ ExpiresAfter: time.Hour * 6,
},
))
- m.Use(macaron.Static(
+ m.Use(public.StaticHandler(
setting.AvatarUploadPath,
- macaron.StaticOptions{
- Prefix: "avatars",
- SkipLogging: setting.DisableRouterLog,
- ETag: true,
+ &public.Options{
+ Prefix: "avatars",
+ SkipLogging: setting.DisableRouterLog,
+ ExpiresAfter: time.Hour * 6,
},
))