Load my selfhost gogs web dom cost about 10s

Hi, this is my selfhost gogs details:

  • Build in CentOS 8 by docker
  • Use SQLite3 as database
  • Git version: 2.24.3
  • Go version: go1.14.7
  • Gogs version: 0.13.0
  1. I have set offline mode equal true
  2. my server bandwidth is 1M, ping is between 7ms to 10ms
  3. the question is load web dom cost 10s

  1. I use a Rere Chrome extension refrict my JS or CSS resouces

    this is the rules

[
	{
		"req": "http://example.com:3000/css/semantic-2.4.2.min.css",
		"res": "https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css",
		"checked": true
	},
	{
		"req": "http://example.com:3000/js/semantic-2.4.2.min.js",
		"res": "https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js",
		"checked": true
	},
	{
		"req": "http://example.com:3000/plugins/highlight-9.18.0/highlight.pack.js",
		"res": "https://cdn.bootcdn.net/ajax/libs/highlight.js/10.3.2/highlight.min.js",
		"checked": true
	},
	{
		"req": "http://example.com:3000/js/jquery-3.4.1.min.js",
		"res": "https://cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js",
		"checked": true
	},
	{
		"req": "http://example.com:3000/js/libs/emojify-1.1.0.min.js",
		"res": "https://cdnjs.cloudflare.com/ajax/libs/emojify.js/1.1.0/js/emojify.min.js",
		"checked": true
	},
	{
		"req": "http://example.com:3000/img/favicon.png",
		"res": "https://gogs.io/img/favicon.png",
		"checked": true
	}
]

1s - 3s

  1. Gogs can support cdn(add a setting in profile) or add a cache control header?

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control

我也遇到这个问题。打开web需要十几秒。能解决嘛

:wave:
其实就是 semantic 的 JS 和 CSS 资源加载问题,我用了一个 Chrome 插件 ReRes 重定向资源到了 cdnjs 的资源上,速度快了很多,因为 cache control 后面的请求是 disk cache

click here: https://i.loli.net/2020/11/20/qBjgwLixCRZb4SX.png