Skip to content

Commit 50bd7d0

Browse files
authored
Remove the service worker (#25010)
It's been disabled by default since 1.17 (#18914), and it never really delivered any benefit except being another cache layer that has its own unsolved invalidation issues. HTTP cache works, we don't need two cache layers at the browser for assets. ## ⚠️ BREAKING You can remove the config `[ui].USE_SERVICE_WORKER` from your `app.ini` now.
1 parent 28a89e3 commit 50bd7d0

File tree

15 files changed

+3
-128
lines changed

15 files changed

+3
-128
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ cpu.out
7676
/yarn-error.log
7777
/npm-debug.log*
7878
/public/js
79-
/public/serviceworker.js
8079
/public/css
8180
/public/fonts
8281
/public/img/webpack

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ cpu.out
7777
/yarn-error.log
7878
/npm-debug.log*
7979
/public/js
80-
/public/serviceworker.js
8180
/public/css
8281
/public/fonts
8382
/public/img/webpack

.ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.min.css
22
*.min.js
3+
/assets/*.json
34
/modules/options/bindata.go
45
/modules/public/bindata.go
56
/modules/templates/bindata.go

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ FOMANTIC_WORK_DIR := web_src/fomantic
114114
WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
115115
WEBPACK_CONFIGS := webpack.config.js
116116
WEBPACK_DEST := public/js/index.js public/css/index.css
117-
WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack public/serviceworker.js
117+
WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack
118118

119119
BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
120120
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))

custom/conf/app.example.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,9 +1208,6 @@ LEVEL = Info
12081208
;; Whether to search within description at repository search on explore page.
12091209
;SEARCH_REPO_DESCRIPTION = true
12101210
;;
1211-
;; Whether to enable a Service Worker to cache frontend assets
1212-
;USE_SERVICE_WORKER = false
1213-
;;
12141211
;; Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
12151212
;; A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
12161213
;ONLY_SHOW_RELEVANT_REPOS = false

docs/content/doc/administration/config-cheat-sheet.en-us.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ The following configuration set `Content-Type: application/vnd.android.package-a
230230
add it to this config.
231231
- `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.
232232
- `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page.
233-
- `USE_SERVICE_WORKER`: **false**: Whether to enable a Service Worker to cache frontend assets.
234233
- `ONLY_SHOW_RELEVANT_REPOS`: **false** Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
235234
A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
236235

modules/setting/ui.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ var UI = struct {
3232
CustomEmojis []string
3333
CustomEmojisMap map[string]string `ini:"-"`
3434
SearchRepoDescription bool
35-
UseServiceWorker bool
3635
OnlyShowRelevantRepos bool
3736

3837
Notification struct {
@@ -136,7 +135,6 @@ func loadUIFrom(rootCfg ConfigProvider) {
136135
UI.ShowUserEmail = sec.Key("SHOW_USER_EMAIL").MustBool(true)
137136
UI.DefaultShowFullName = sec.Key("DEFAULT_SHOW_FULL_NAME").MustBool(false)
138137
UI.SearchRepoDescription = sec.Key("SEARCH_REPO_DESCRIPTION").MustBool(true)
139-
UI.UseServiceWorker = sec.Key("USE_SERVICE_WORKER").MustBool(false)
140138

141139
// OnlyShowRelevantRepos=false is important for many private/enterprise instances,
142140
// because many private repositories do not have "description/topic", users just want to search by their names.

modules/templates/helper.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ func NewFuncMap() template.FuncMap {
127127
"MetaKeywords": func() string {
128128
return setting.UI.Meta.Keywords
129129
},
130-
"UseServiceWorker": func() bool {
131-
return setting.UI.UseServiceWorker
132-
},
133130
"EnableTimetracking": func() bool {
134131
return setting.Service.EnableTimetracking
135132
},

package-lock.json

Lines changed: 0 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@
5151
"vue3-calendar-heatmap": "2.0.5",
5252
"webpack": "5.84.1",
5353
"webpack-cli": "5.1.1",
54-
"workbox-routing": "6.6.0",
55-
"workbox-strategies": "6.6.0",
5654
"wrap-ansi": "8.1.0"
5755
},
5856
"devDependencies": {

templates/base/head_script.tmpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly.
1212
assetUrlPrefix: '{{AssetUrlPrefix}}',
1313
runModeIsProd: {{.RunModeIsProd}},
1414
customEmojis: {{CustomEmojis}},
15-
useServiceWorker: {{UseServiceWorker}},
1615
csrfToken: '{{.CsrfToken}}',
1716
pageData: {{.PageData}},
1817
notificationSettings: {{NotificationSettings}}, {{/*a map provided by NewFuncMap in helper.go*/}}

web_src/js/features/serviceworker.js

Lines changed: 0 additions & 57 deletions
This file was deleted.

web_src/js/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {initHeatmap} from './features/heatmap.js';
1111
import {initImageDiff} from './features/imagediff.js';
1212
import {initRepoMigration} from './features/repo-migration.js';
1313
import {initRepoProject} from './features/repo-projects.js';
14-
import {initServiceWorker} from './features/serviceworker.js';
1514
import {initTableSort} from './features/tablesort.js';
1615
import {initAdminUserListSearchForm} from './features/admin/users.js';
1716
import {initAdminConfigs} from './features/admin/config.js';
@@ -116,7 +115,6 @@ onDomReady(() => {
116115
initImageDiff();
117116
initMarkupAnchors();
118117
initMarkupContent();
119-
initServiceWorker();
120118
initSshKeyFormParser();
121119
initStopwatch();
122120
initTableSort();

web_src/js/serviceworker.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

webpack.config.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ export default {
6262
fileURLToPath(new URL('web_src/js/standalone/swagger.js', import.meta.url)),
6363
fileURLToPath(new URL('web_src/css/standalone/swagger.css', import.meta.url)),
6464
],
65-
serviceworker: [
66-
fileURLToPath(new URL('web_src/js/serviceworker.js', import.meta.url)),
67-
],
6865
'eventsource.sharedworker': [
6966
fileURLToPath(new URL('web_src/js/features/eventsource.sharedworker.js', import.meta.url)),
7067
],
@@ -73,11 +70,7 @@ export default {
7370
devtool: false,
7471
output: {
7572
path: fileURLToPath(new URL('public', import.meta.url)),
76-
filename: ({chunk}) => {
77-
// serviceworker can only manage assets below it's script's directory so
78-
// we have to put it in / instead of /js/
79-
return chunk.name === 'serviceworker' ? '[name].js' : 'js/[name].js';
80-
},
73+
filename: () => 'js/[name].js',
8174
chunkFilename: ({chunk}) => {
8275
const language = (/monaco.*languages?_.+?_(.+?)_/.exec(chunk.id) || [])[1];
8376
return `js/${language ? `monaco-language-${language.toLowerCase()}` : `[name]`}.[contenthash:8].js`;

0 commit comments

Comments
 (0)