diff options
author | silverwind <me@silverwind.io> | 2022-08-23 14:58:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 20:58:04 +0800 |
commit | 56220515fc882943e366fafbce4d5b2b3ccee702 (patch) | |
tree | d64bffc3a9d13ce01bf56aedc896923aa4af0acf /modules/setting/setting.go | |
parent | 0a9ed54abbe8b6837dcb22a35b744c11f410421f (diff) | |
download | gitea-56220515fc882943e366fafbce4d5b2b3ccee702.tar.gz gitea-56220515fc882943e366fafbce4d5b2b3ccee702.zip |
Enable contenthash in filename for dynamic assets (#20813)
This should solve the main problem of dynamic assets getting stale after
a version upgrade. Everything not affected will use query-string based
cache busting, which includes files loaded via HTML or worker scripts.
Diffstat (limited to 'modules/setting/setting.go')
-rw-r--r-- | modules/setting/setting.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 931b6523ea..becd52f011 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -92,6 +92,8 @@ var ( // LocalURL is the url for locally running applications to contact Gitea. It always has a '/' suffix // It maps to ini:"LOCAL_ROOT_URL" LocalURL string + // AssetVersion holds a opaque value that is used for cache-busting assets + AssetVersion string // Server settings Protocol Scheme @@ -759,6 +761,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) { } AbsoluteAssetURL = MakeAbsoluteAssetURL(AppURL, StaticURLPrefix) + AssetVersion = strings.ReplaceAll(AppVer, "+", "~") // make sure the version string is clear (no real escaping is needed) manifestBytes := MakeManifestData(AppName, AppURL, AbsoluteAssetURL) ManifestData = `application/json;base64,` + base64.StdEncoding.EncodeToString(manifestBytes) |