diff options
author | default <nobody@localhost> | 2022-09-30 09:56:29 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2022-09-30 09:56:29 +0200 |
commit | 3d544233a63a2105d8d91e7fd4f62f7703fef6e0 (patch) | |
tree | 021cca6da8ae40a6fbc3e8fb73499f0f9777044b /html.c | |
parent | 41767992960f4a60a34b212d9ae3d25e9ca2a3f8 (diff) |
Timeline is cached.
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -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 |