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/browse.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/browse.go')
-rw-r--r--pkg/app/list/browse.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/pkg/app/list/browse.go b/pkg/app/list/browse.go
index fdc3ab1..5d8457e 100644
--- a/pkg/app/list/browse.go
+++ b/pkg/app/list/browse.go
@@ -1,6 +1,7 @@
package list
import (
+ "archives/pkg/cache"
"archives/pkg/config"
"archives/pkg/database"
"archives/pkg/models"
@@ -8,7 +9,15 @@ import (
)
func Browse(w http.ResponseWriter, r *http.Request) {
+ templateData := cache.Get("/lists")
+ if templateData == nil {
+ http.NotFound(w,r)
+ return
+ }
+ renderBrowseTemplate(w, templateData)
+}
+func ComputeBrowseTemplateData() interface{} {
var res []struct {
Name string
MessageCount int
@@ -19,8 +28,7 @@ func Browse(w http.ResponseWriter, r *http.Request) {
Select(&res)
if err != nil {
- http.NotFound(w,r)
- return
+ return nil
}
var currentMailingLists []models.MailingList
@@ -40,18 +48,15 @@ func Browse(w http.ResponseWriter, r *http.Request) {
}
}
- browseData := struct {
+ return struct {
CurrentMailingLists []models.MailingList
FrozenArchives []models.MailingList
}{
CurrentMailingLists: currentMailingLists,
FrozenArchives: frozenArchives,
}
-
- renderBrowseTemplate(w, browseData)
}
-
func contains(s []string, e string) bool {
for _, a := range s {
if a == e {