summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-09-30 09:56:29 +0200
committerdefault <nobody@localhost>2022-09-30 09:56:29 +0200
commit3d544233a63a2105d8d91e7fd4f62f7703fef6e0 (patch)
tree021cca6da8ae40a6fbc3e8fb73499f0f9777044b /html.c
parent41767992960f4a60a34b212d9ae3d25e9ca2a3f8 (diff)
Timeline is cached.
Diffstat (limited to 'html.c')
-rw-r--r--html.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/html.c b/html.c
index fc42fb3..fd6fbdf 100644
--- a/html.c
+++ b/html.c
@@ -713,11 +713,24 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
if (!login(&snac, req))
status = 401;
else {
- xs *list = timeline_list(&snac, 0xfffffff);
+ if (history_mtime(&snac, "_timeline.html") > timeline_mtime(&snac)) {
+ snac_debug(&snac, 1, xs_fmt("serving cached timeline"));
- *body = html_timeline(&snac, list, 0);
- *b_size = strlen(*body);
- status = 200;
+ *body = history_get(&snac, "_timeline.html");
+ *b_size = strlen(*body);
+ status = 200;
+ }
+ else {
+ snac_debug(&snac, 1, xs_fmt("building timeline"));
+
+ xs *list = timeline_list(&snac, 0xfffffff);
+
+ *body = html_timeline(&snac, list, 0);
+ *b_size = strlen(*body);
+ status = 200;
+
+ history_add(&snac, "_timeline.html", *body, *b_size);
+ }
}
}
else