mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 04:05:42 +01:00
Make static resouces web browser cache time customized on app.ini (#8442)
* make static resouces web browser cache time customized on app.ini * Update docs/content/doc/advanced/config-cheat-sheet.en-us.md Co-Authored-By: zeripath <art27@cantab.net> * Update custom/conf/app.ini.sample Co-Authored-By: Antoine GIRARD <sapk@users.noreply.github.com> * fix docs
This commit is contained in:
parent
b6ef539ef4
commit
0be992a1e2
5 changed files with 10 additions and 4 deletions
|
@ -243,6 +243,8 @@ LFS_CONTENT_PATH = data/lfs
|
|||
LFS_JWT_SECRET =
|
||||
; LFS authentication validity period (in time.Duration), pushes taking longer than this may fail.
|
||||
LFS_HTTP_AUTH_EXPIRY = 20m
|
||||
; Static resources, includes resources on custom/, public/ and all uploaded avatars web browser cache time, default is 6h
|
||||
STATIC_CACHE_TIME = 6h
|
||||
|
||||
; Define allowed algorithms and their minimum key length (use -1 to disable a type)
|
||||
[ssh.minimum_key_sizes]
|
||||
|
|
|
@ -140,6 +140,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
|
|||
- `CERT_FILE`: **custom/https/cert.pem**: Cert file path used for HTTPS.
|
||||
- `KEY_FILE`: **custom/https/key.pem**: Key file path used for HTTPS.
|
||||
- `STATIC_ROOT_PATH`: **./**: Upper level of template and static files path.
|
||||
- `STATIC_CACHE_TIME`: **6h**: Web browser cache time for static resources on `custom/`, `public/` and all uploaded avatars.
|
||||
- `ENABLE_GZIP`: **false**: Enables application-level GZIP support.
|
||||
- `LANDING_PAGE`: **home**: Landing page for unauthenticated users \[home, explore\].
|
||||
- `LFS_START_SERVER`: **false**: Enables git-lfs support.
|
||||
|
|
|
@ -65,6 +65,7 @@ menu:
|
|||
- `CERT_FILE`: 启用HTTPS的证书文件。
|
||||
- `KEY_FILE`: 启用HTTPS的密钥文件。
|
||||
- `STATIC_ROOT_PATH`: 存放模板和静态文件的根目录,默认是 Gitea 的根目录。
|
||||
- `STATIC_CACHE_TIME`: **6h**: 静态资源文件,包括 `custom/`, `public/` 和所有上传的头像的浏览器缓存时间。
|
||||
- `ENABLE_GZIP`: 启用应用级别的 GZIP 压缩。
|
||||
- `LANDING_PAGE`: 未登录用户的默认页面,可选 `home` 或 `explore`。
|
||||
- `LFS_START_SERVER`: 是否启用 git-lfs 支持. 可以为 `true` 或 `false`, 默认是 `false`。
|
||||
|
|
|
@ -87,6 +87,7 @@ var (
|
|||
CertFile string
|
||||
KeyFile string
|
||||
StaticRootPath string
|
||||
StaticCacheTime time.Duration
|
||||
EnableGzip bool
|
||||
LandingPageURL LandingPage
|
||||
UnixSocketPermission uint32
|
||||
|
@ -607,6 +608,7 @@ func NewContext() {
|
|||
OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
|
||||
DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
|
||||
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(AppWorkPath)
|
||||
StaticCacheTime = sec.Key("STATIC_CACHE_TIME").MustDuration(6 * time.Hour)
|
||||
AppDataPath = sec.Key("APP_DATA_PATH").MustString(path.Join(AppWorkPath, "data"))
|
||||
EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
|
||||
EnablePprof = sec.Key("ENABLE_PPROF").MustBool(false)
|
||||
|
|
|
@ -139,14 +139,14 @@ func NewMacaron() *macaron.Macaron {
|
|||
m.Use(public.Custom(
|
||||
&public.Options{
|
||||
SkipLogging: setting.DisableRouterLog,
|
||||
ExpiresAfter: time.Hour * 6,
|
||||
ExpiresAfter: setting.StaticCacheTime,
|
||||
},
|
||||
))
|
||||
m.Use(public.Static(
|
||||
&public.Options{
|
||||
Directory: path.Join(setting.StaticRootPath, "public"),
|
||||
SkipLogging: setting.DisableRouterLog,
|
||||
ExpiresAfter: time.Hour * 6,
|
||||
ExpiresAfter: setting.StaticCacheTime,
|
||||
},
|
||||
))
|
||||
m.Use(public.StaticHandler(
|
||||
|
@ -154,7 +154,7 @@ func NewMacaron() *macaron.Macaron {
|
|||
&public.Options{
|
||||
Prefix: "avatars",
|
||||
SkipLogging: setting.DisableRouterLog,
|
||||
ExpiresAfter: time.Hour * 6,
|
||||
ExpiresAfter: setting.StaticCacheTime,
|
||||
},
|
||||
))
|
||||
m.Use(public.StaticHandler(
|
||||
|
@ -162,7 +162,7 @@ func NewMacaron() *macaron.Macaron {
|
|||
&public.Options{
|
||||
Prefix: "repo-avatars",
|
||||
SkipLogging: setting.DisableRouterLog,
|
||||
ExpiresAfter: time.Hour * 6,
|
||||
ExpiresAfter: setting.StaticCacheTime,
|
||||
},
|
||||
))
|
||||
|
||||
|
|
Loading…
Reference in a new issue