aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Magorsch <arzano@gentoo.org>2020-06-22 19:33:07 +0200
committerMax Magorsch <arzano@gentoo.org>2020-06-22 19:33:07 +0200
commitb9d384f9d788f83c4b21b708bc5920c58efb3ce5 (patch)
tree0856ec2b5eb420f5b2a4dd86a6fcbb90508573dc /pkg/app/list/show.go
parentImprove the performance of the importer (diff)
downloadarchives-b9d384f9d788f83c4b21b708bc5920c58efb3ce5.tar.gz
archives-b9d384f9d788f83c4b21b708bc5920c58efb3ce5.tar.bz2
archives-b9d384f9d788f83c4b21b708bc5920c58efb3ce5.zip
Cache pages to improve the performance
Some pages as the landing page or the lists overview page are cached now to improve the performance. Signed-off-by: Max Magorsch <arzano@gentoo.org>
Diffstat (limited to 'pkg/app/list/show.go')
-rw-r--r--pkg/app/list/show.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/pkg/app/list/show.go b/pkg/app/list/show.go
index d90f236..5231b5b 100644
--- a/pkg/app/list/show.go
+++ b/pkg/app/list/show.go
@@ -1,6 +1,7 @@
package list
import (
+ "archives/pkg/cache"
"archives/pkg/database"
"archives/pkg/models"
"github.com/go-pg/pg/v10/orm"
@@ -9,9 +10,17 @@ import (
)
func Show(w http.ResponseWriter, r *http.Request) {
-
listName := strings.ReplaceAll(r.URL.Path, "/", "")
+ templateData := cache.Get("/" + listName + "/")
+ if templateData == nil {
+ http.NotFound(w,r)
+ return
+ }
+ renderShowTemplate(w, listName, templateData)
+}
+
+func ComputeShowTemplateData(listName string) interface{} {
var res []struct {
CombinedDate string
MessageCount int
@@ -36,9 +45,7 @@ func Show(w http.ResponseWriter, r *http.Request) {
Select(&res)
if err != nil {
- http.NotFound(w, r)
- return
+ return nil
}
-
- renderShowTemplate(w, listName, res)
-}
+ return res
+} \ No newline at end of file