From d512e7f8175d1843f4c8108b6c56dd2e331e7ce5 Mon Sep 17 00:00:00 2001 From: HynoR <20227709+HynoR@users.noreply.github.com> Date: Sun, 30 Nov 2025 10:12:49 +0800 Subject: [PATCH 1/4] perf: use gzipped data for improved load speed in big files --- agent/app/api/v2/dashboard.go | 2 +- agent/app/api/v2/file.go | 6 +++++- agent/app/api/v2/monitor.go | 2 +- agent/app/api/v2/website_ssl.go | 7 ++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/agent/app/api/v2/dashboard.go b/agent/app/api/v2/dashboard.go index 64cde1294243..9cdc21a8ae3b 100644 --- a/agent/app/api/v2/dashboard.go +++ b/agent/app/api/v2/dashboard.go @@ -37,7 +37,7 @@ func (b *BaseApi) LoadAppLauncher(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithData(c, data) + helper.SuccessWithDataGzipped(c, data) } // @Tags Dashboard diff --git a/agent/app/api/v2/file.go b/agent/app/api/v2/file.go index 44753f332713..f26ac4df11f3 100644 --- a/agent/app/api/v2/file.go +++ b/agent/app/api/v2/file.go @@ -265,7 +265,11 @@ func (b *BaseApi) GetContent(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithData(c, info) + if info.Size > 10*1024 { + helper.SuccessWithDataGzipped(c, info) + } else { + helper.SuccessWithData(c, info) + } } // @Tags File diff --git a/agent/app/api/v2/monitor.go b/agent/app/api/v2/monitor.go index da122dd13558..a0b03ba21af2 100644 --- a/agent/app/api/v2/monitor.go +++ b/agent/app/api/v2/monitor.go @@ -28,7 +28,7 @@ func (b *BaseApi) LoadMonitor(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithData(c, data) + helper.SuccessWithDataGzipped(c, data) } // @Tags Monitor diff --git a/agent/app/api/v2/website_ssl.go b/agent/app/api/v2/website_ssl.go index ee0a91e97e17..b00d71f2c9a3 100644 --- a/agent/app/api/v2/website_ssl.go +++ b/agent/app/api/v2/website_ssl.go @@ -1,7 +1,6 @@ package v2 import ( - "github.com/1Panel-dev/1Panel/agent/app/model" "io" "mime/multipart" "net/http" @@ -9,6 +8,8 @@ import ( "reflect" "strconv" + "github.com/1Panel-dev/1Panel/agent/app/model" + "github.com/1Panel-dev/1Panel/agent/app/api/v2/helper" "github.com/1Panel-dev/1Panel/agent/app/dto" "github.com/1Panel-dev/1Panel/agent/app/dto/request" @@ -34,7 +35,7 @@ func (b *BaseApi) PageWebsiteSSL(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithData(c, dto.PageResult{ + helper.SuccessWithDataGzipped(c, dto.PageResult{ Total: total, Items: accounts, }) @@ -44,7 +45,7 @@ func (b *BaseApi) PageWebsiteSSL(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithData(c, list) + helper.SuccessWithDataGzipped(c, list) } } From df8624efd50efb9914a42dac2e883ade46794866 Mon Sep 17 00:00:00 2001 From: HynoR <20227709+HynoR@users.noreply.github.com> Date: Sun, 30 Nov 2025 10:19:39 +0800 Subject: [PATCH 2/4] perf: switch to gzipped response for GetFileTree to enhance performance --- agent/app/api/v2/file.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/app/api/v2/file.go b/agent/app/api/v2/file.go index f26ac4df11f3..d4bccd25326e 100644 --- a/agent/app/api/v2/file.go +++ b/agent/app/api/v2/file.go @@ -90,7 +90,7 @@ func (b *BaseApi) GetFileTree(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithData(c, tree) + helper.SuccessWithDataGzipped(c, tree) } // @Tags File From c12f7e1fd36a72f663f0afb17366d69f6100738b Mon Sep 17 00:00:00 2001 From: HynoR <20227709+HynoR@users.noreply.github.com> Date: Sun, 30 Nov 2025 10:26:49 +0800 Subject: [PATCH 3/4] perf: switch to gzipped response for SearchApp to improve performance --- agent/app/api/v2/app.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/agent/app/api/v2/app.go b/agent/app/api/v2/app.go index c462e04447cb..5e0cd1df8ace 100644 --- a/agent/app/api/v2/app.go +++ b/agent/app/api/v2/app.go @@ -1,13 +1,14 @@ package v2 import ( + "net/http" + "time" + "github.com/1Panel-dev/1Panel/agent/app/api/v2/helper" "github.com/1Panel-dev/1Panel/agent/app/dto" "github.com/1Panel-dev/1Panel/agent/app/dto/request" "github.com/1Panel-dev/1Panel/agent/i18n" "github.com/gin-gonic/gin" - "net/http" - "time" ) // @Tags App @@ -28,7 +29,7 @@ func (b *BaseApi) SearchApp(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithData(c, list) + helper.SuccessWithDataGzipped(c, list) } // @Tags App From 5e426827aaa7b3211622187e68026714b7d76f16 Mon Sep 17 00:00:00 2001 From: HynoR <20227709+HynoR@users.noreply.github.com> Date: Sun, 30 Nov 2025 10:38:53 +0800 Subject: [PATCH 4/4] perf: update file size conditions for gzipped response to enhance performance --- agent/app/api/v2/file.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/app/api/v2/file.go b/agent/app/api/v2/file.go index d4bccd25326e..1e4bdacec41c 100644 --- a/agent/app/api/v2/file.go +++ b/agent/app/api/v2/file.go @@ -265,7 +265,7 @@ func (b *BaseApi) GetContent(c *gin.Context) { helper.InternalServer(c, err) return } - if info.Size > 10*1024 { + if info.Size > 2*1024 && info.Size < 5*1024*1024 { helper.SuccessWithDataGzipped(c, info) } else { helper.SuccessWithData(c, info)