From 61c7732e1218433069c319b1c590ee738775f899 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 7 Apr 2022 20:08:24 +0200 Subject: [PATCH] Disable service worker by default (#18914) (#19342) The service worker causes a lot of issues with JS errors after instance upgrades while not bringing any real performance gain over regular HTTP caching. Disable it by default for this reason. Maybe later we can remove it completely, as I simply see no benefit in having it. --- custom/conf/app.example.ini | 2 +- docs/content/doc/advanced/config-cheat-sheet.en-us.md | 2 +- docs/content/doc/developers/hacking-on-gitea.en-us.md | 2 -- modules/setting/setting.go | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 586c924c4a..8d7946145f 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1075,7 +1075,7 @@ PATH = ;SEARCH_REPO_DESCRIPTION = true ;; ;; Whether to enable a Service Worker to cache frontend assets -;USE_SERVICE_WORKER = true +;USE_SERVICE_WORKER = false ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 6cbc9b91f9..c4fbe3867f 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -189,7 +189,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a add it to this config. - `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used. - `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page. -- `USE_SERVICE_WORKER`: **true**: Whether to enable a Service Worker to cache frontend assets. +- `USE_SERVICE_WORKER`: **false**: Whether to enable a Service Worker to cache frontend assets. ### UI - Admin (`ui.admin`) diff --git a/docs/content/doc/developers/hacking-on-gitea.en-us.md b/docs/content/doc/developers/hacking-on-gitea.en-us.md index 5481a2f1fe..be04e6efc4 100644 --- a/docs/content/doc/developers/hacking-on-gitea.en-us.md +++ b/docs/content/doc/developers/hacking-on-gitea.en-us.md @@ -185,8 +185,6 @@ Before committing, make sure the linters pass: make lint-frontend ``` -Note: When working on frontend code, set `USE_SERVICE_WORKER` to `false` in `app.ini` to prevent undesirable caching of frontend assets. - ### Building and adding SVGs SVG icons are built using the `make svg` target which compiles the icon sources defined in `build/generate-svg.js` into the output directory `public/img/svg`. Custom icons can be added in the `web_src/svg` directory. diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 2701658f65..c9f180bd46 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -1010,7 +1010,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) { UI.ShowUserEmail = Cfg.Section("ui").Key("SHOW_USER_EMAIL").MustBool(true) UI.DefaultShowFullName = Cfg.Section("ui").Key("DEFAULT_SHOW_FULL_NAME").MustBool(false) UI.SearchRepoDescription = Cfg.Section("ui").Key("SEARCH_REPO_DESCRIPTION").MustBool(true) - UI.UseServiceWorker = Cfg.Section("ui").Key("USE_SERVICE_WORKER").MustBool(true) + UI.UseServiceWorker = Cfg.Section("ui").Key("USE_SERVICE_WORKER").MustBool(false) HasRobotsTxt, err = util.IsFile(path.Join(CustomPath, "robots.txt")) if err != nil {