diff --git a/Makefile b/Makefile
index 890332fde1e43..3aefafa61216f 100644
--- a/Makefile
+++ b/Makefile
@@ -96,7 +96,7 @@ FOMANTIC_DEST_DIR := web_src/fomantic/build
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f) $(FOMANTIC_DEST)
WEBPACK_CONFIGS := webpack.config.js
WEBPACK_DEST := public/js/index.js public/css/index.css
-WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack public/serviceworker.js
+WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack
BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
diff --git a/README.md b/README.md
index e46ae4cd1af7c..4199390bfc655 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
[简体中文](README_ZH.md)
-
Gitea - Git with a cup of tea
+
Gitea - Git with a cup of tea
[](https://drone.gitea.io/go-gitea/gitea)
[](https://discord.gg/Gitea)
diff --git a/README_ZH.md b/README_ZH.md
index 5163e336d2eb4..fd78ed829adfc 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -1,6 +1,6 @@
[English](README.md)
-
Gitea - Git with a cup of tea
+
Gitea - Git with a cup of tea
[](https://drone.gitea.io/go-gitea/gitea)
[](https://discord.gg/Gitea)
diff --git a/build/generate-images.js b/build/generate-images.js
index 9b7b8201720eb..111034f30e32d 100755
--- a/build/generate-images.js
+++ b/build/generate-images.js
@@ -89,8 +89,6 @@ async function main() {
const svg = await readFile(resolve(__dirname, '../assets/logo.svg'), 'utf8');
await generateSvgFavicon(svg, resolve(__dirname, '../public/img/favicon.svg'));
await generate(svg, resolve(__dirname, '../public/img/gitea-lg.png'), {size: 880});
- await generate(svg, resolve(__dirname, '../public/img/gitea-512.png'), {size: 512});
- await generate(svg, resolve(__dirname, '../public/img/gitea-192.png'), {size: 192});
await generate(svg, resolve(__dirname, '../public/img/gitea-sm.png'), {size: 120});
await generate(svg, resolve(__dirname, '../public/img/avatar_default.png'), {size: 200});
await generate(svg, resolve(__dirname, '../public/img/favicon.png'), {size: 180, removeDetail: true});
diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini
index f8c631ee0718e..77ecb088396b4 100644
--- a/custom/conf/app.example.ini
+++ b/custom/conf/app.example.ini
@@ -190,8 +190,6 @@ REACTIONS = +1, -1, laugh, hooray, confused, heart, rocket, eyes
DEFAULT_SHOW_FULL_NAME = false
; Whether to search within description at repository search on explore page.
SEARCH_REPO_DESCRIPTION = true
-; Whether to enable a Service Worker to cache frontend assets
-USE_SERVICE_WORKER = true
[ui.admin]
; Number of users that are displayed on one page
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 39fc350e4f40a..3be1726dad40b 100644
--- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md
+++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md
@@ -137,7 +137,6 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
For custom reactions, add a tightly cropped square image to public/emoji/img/reaction_name.png
- `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.
### UI - Admin (`ui.admin`)
diff --git a/docs/content/doc/advanced/hacking-on-gitea.en-us.md b/docs/content/doc/advanced/hacking-on-gitea.en-us.md
index b24260c68a42a..6a8daa1b01d08 100644
--- a/docs/content/doc/advanced/hacking-on-gitea.en-us.md
+++ b/docs/content/doc/advanced/hacking-on-gitea.en-us.md
@@ -151,8 +151,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 d4ce13079a581..9f562cbf74838 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -179,7 +179,6 @@ var (
Reactions []string
ReactionsMap map[string]bool
SearchRepoDescription bool
- UseServiceWorker bool
Notification struct {
MinTimeout time.Duration
@@ -1012,7 +1011,6 @@ func NewContext() {
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)
HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 718fe8f2672ec..7cb38fd537cd1 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -169,9 +169,6 @@ func NewFuncMap() []template.FuncMap {
"MetaKeywords": func() string {
return setting.UI.Meta.Keywords
},
- "UseServiceWorker": func() bool {
- return setting.UI.UseServiceWorker
- },
"FilenameIsImage": func(filename string) bool {
mimeType := mime.TypeByExtension(filepath.Ext(filename))
return strings.HasPrefix(mimeType, "image/")
diff --git a/package-lock.json b/package-lock.json
index 415fb38016084..41bba720a908b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -14688,28 +14688,6 @@
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
"integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8="
},
- "workbox-core": {
- "version": "5.1.3",
- "resolved": "https://registry.npmjs.org/workbox-core/-/workbox-core-5.1.3.tgz",
- "integrity": "sha512-TFSIPxxciX9sFaj0FDiohBeIKpwMcCyNduydi9i3LChItcndDS6TJpErxybv8aBWeCMraXt33TWtF6kKuIObNw=="
- },
- "workbox-routing": {
- "version": "5.1.3",
- "resolved": "https://registry.npmjs.org/workbox-routing/-/workbox-routing-5.1.3.tgz",
- "integrity": "sha512-F+sAp9Iy3lVl3BEG+pzXWVq4AftzjiFpHDaZ4Kf4vLoBoKQE0hIHet4zE5DpHqYdyw+Udhp4wrfHamX6PN6z1Q==",
- "requires": {
- "workbox-core": "^5.1.3"
- }
- },
- "workbox-strategies": {
- "version": "5.1.3",
- "resolved": "https://registry.npmjs.org/workbox-strategies/-/workbox-strategies-5.1.3.tgz",
- "integrity": "sha512-wiXHfmOKnWABeIVW+/ye0e00+2CcS5y7SIj2f9zcdy2ZLEbcOf7B+yOl5OrWpBGlTUwRjIYhV++ZqiKm3Dc+8w==",
- "requires": {
- "workbox-core": "^5.1.3",
- "workbox-routing": "^5.1.3"
- }
- },
"worker-farm": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.7.0.tgz",
diff --git a/package.json b/package.json
index d2980e93035d5..73c42609dee28 100644
--- a/package.json
+++ b/package.json
@@ -45,8 +45,6 @@
"webpack": "4.44.0",
"webpack-cli": "3.3.12",
"webpack-fix-style-only-entries": "0.5.1",
- "workbox-routing": "5.1.3",
- "workbox-strategies": "5.1.3",
"worker-loader": "2.0.0",
"wrap-ansi": "7.0.0"
},
diff --git a/public/img/gitea-512.png b/public/img/gitea-512.png
deleted file mode 100644
index 7b32fb33b6084..0000000000000
Binary files a/public/img/gitea-512.png and /dev/null differ
diff --git a/routers/routes/routes.go b/routers/routes/routes.go
index d739f0b6ca5d2..643a8e9550e6b 100644
--- a/routers/routes/routes.go
+++ b/routers/routes/routes.go
@@ -1043,11 +1043,6 @@ func RegisterRoutes(m *macaron.Macaron) {
ctx.Redirect(path.Join(setting.StaticURLPrefix, "img/apple-touch-icon.png"), 301)
})
- // Progressive Web App
- m.Get("/manifest.json", templates.JSONRenderer(), func(ctx *context.Context) {
- ctx.HTML(200, "pwa/manifest_json")
- })
-
// prometheus metrics endpoint
if setting.Metrics.Enabled {
c := metrics.NewCollector()
diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl
index 0760354e43068..e86f528cac905 100644
--- a/templates/base/head.tmpl
+++ b/templates/base/head.tmpl
@@ -5,7 +5,6 @@
{{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}} {{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}}
-
@@ -30,7 +29,6 @@
AppVer: '{{AppVer}}',
AppSubUrl: '{{AppSubUrl}}',
StaticUrlPrefix: '{{StaticUrlPrefix}}',
- UseServiceWorker: {{UseServiceWorker}},
csrf: '{{.CsrfToken}}',
HighlightJS: {{if .RequireHighlightJS}}true{{else}}false{{end}},
SimpleMDE: {{if .RequireSimpleMDE}}true{{else}}false{{end}},
diff --git a/templates/pwa/manifest_json.tmpl b/templates/pwa/manifest_json.tmpl
deleted file mode 100644
index 793b42f2e1c89..0000000000000
--- a/templates/pwa/manifest_json.tmpl
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "short_name": "Gitea",
- "name": "Gitea - Git with a cup of tea",
- "icons": [
- {
- "src": "{{StaticUrlPrefix}}/img/gitea-lg.png",
- "type": "image/png",
- "sizes": "880x880"
- },
- {
- "src": "{{StaticUrlPrefix}}/img/gitea-sm.png",
- "type": "image/png",
- "sizes": "120x120"
- },
- {
- "src": "{{StaticUrlPrefix}}/img/gitea-512.png",
- "type": "image/png",
- "sizes": "512x512"
- },
- {
- "src": "{{StaticUrlPrefix}}/img/gitea-192.png",
- "type": "image/png",
- "sizes": "192x192"
- }
- ],
- "start_url": "{{AppSubUrl}}/",
- "scope": "{{AppSubUrl}}/",
- "background_color": "#FAFAFA",
- "display": "standalone",
- "theme_color": "{{ThemeColorMetaTag}}"
- }
diff --git a/web_src/js/features/serviceworker.js b/web_src/js/features/serviceworker.js
index fa415866cd299..407ac55295fda 100644
--- a/web_src/js/features/serviceworker.js
+++ b/web_src/js/features/serviceworker.js
@@ -1,7 +1,5 @@
-const {UseServiceWorker, AppSubUrl, AppVer} = window.config;
-const cachePrefix = 'static-cache-v'; // actual version is set in the service worker script
-
async function unregister() {
+ if (!('serviceWorker' in navigator)) return;
const registrations = await navigator.serviceWorker.getRegistrations();
await Promise.all(registrations.map((registration) => {
return registration.active && registration.unregister();
@@ -9,45 +7,17 @@ async function unregister() {
}
async function invalidateCache() {
+ if (!caches || !caches.keys) return;
const cacheKeys = await caches.keys();
await Promise.all(cacheKeys.map((key) => {
- return key.startsWith(cachePrefix) && caches.delete(key);
+ return key.startsWith('static-cache-v') && caches.delete(key);
}));
}
-async function checkCacheValidity() {
- const cacheKey = AppVer;
- const storedCacheKey = localStorage.getItem('staticCacheKey');
-
- // invalidate cache if it belongs to a different gitea version
- if (cacheKey && storedCacheKey !== cacheKey) {
- await invalidateCache();
- localStorage.setItem('staticCacheKey', cacheKey);
- }
-}
-
export default async function initServiceWorker() {
- if (!('serviceWorker' in navigator)) return;
-
- if (UseServiceWorker) {
- try {
- // normally we'd serve the service worker as a static asset from StaticUrlPrefix but
- // the spec strictly requires it to be same-origin so it has to be AppSubUrl to work
- await Promise.all([
- checkCacheValidity(),
- navigator.serviceWorker.register(`${AppSubUrl}/serviceworker.js`),
- ]);
- } catch (err) {
- console.error(err);
- await Promise.all([
- invalidateCache(),
- unregister(),
- ]);
- }
- } else {
- await Promise.all([
- invalidateCache(),
- unregister(),
- ]);
- }
+ // we once had a service worker, if it's present, remove it and wipe its cache
+ await Promise.all([
+ invalidateCache(),
+ unregister(),
+ ]);
}
diff --git a/web_src/js/serviceworker.js b/web_src/js/serviceworker.js
deleted file mode 100644
index c96ef8bd97ffe..0000000000000
--- a/web_src/js/serviceworker.js
+++ /dev/null
@@ -1,23 +0,0 @@
-import {registerRoute} from 'workbox-routing';
-import {StaleWhileRevalidate} from 'workbox-strategies';
-
-const cacheName = 'static-cache-v2';
-
-// disable workbox debug logging in development, remove when debugging the service worker
-self.__WB_DISABLE_DEV_LOGS = true;
-
-// see https://developer.mozilla.org/en-US/docs/Web/API/RequestDestination for possible values
-const cachedDestinations = new Set([
- 'font',
- 'manifest',
- 'paintworklet',
- 'script',
- 'sharedworker',
- 'style',
- 'worker',
-]);
-
-registerRoute(
- ({request}) => cachedDestinations.has(request.destination),
- new StaleWhileRevalidate({cacheName}),
-);
diff --git a/webpack.config.js b/webpack.config.js
index e733a7784ed5a..bba849fef37bc 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -50,9 +50,6 @@ module.exports = {
swagger: [
resolve(__dirname, 'web_src/js/standalone/swagger.js'),
],
- serviceworker: [
- resolve(__dirname, 'web_src/js/serviceworker.js'),
- ],
'eventsource.sharedworker': [
resolve(__dirname, 'web_src/js/features/eventsource.sharedworker.js'),
],
@@ -61,11 +58,7 @@ module.exports = {
devtool: false,
output: {
path: resolve(__dirname, 'public'),
- filename: ({chunk}) => {
- // serviceworker can only manage assets below it's script's directory so
- // we have to put it in / instead of /js/
- return chunk.name === 'serviceworker' ? '[name].js' : 'js/[name].js';
- },
+ filename: 'js/[name].js',
chunkFilename: 'js/[name].js',
},
optimization: {