mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 17:45:04 +00:00
New optional server config directive 'disable_cache'.
This commit is contained in:
parent
0b39d08d80
commit
305591ae31
1 changed files with 8 additions and 2 deletions
10
html.c
10
html.c
|
@ -708,6 +708,8 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
|
||||||
int status = 404;
|
int status = 404;
|
||||||
snac snac;
|
snac snac;
|
||||||
char *uid, *p_path;
|
char *uid, *p_path;
|
||||||
|
int cache = 1;
|
||||||
|
char *v;
|
||||||
|
|
||||||
xs *l = xs_split_n(q_path, "/", 2);
|
xs *l = xs_split_n(q_path, "/", 2);
|
||||||
|
|
||||||
|
@ -718,13 +720,17 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
|
||||||
return 404;
|
return 404;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check if server config variable 'disable_cache' is set */
|
||||||
|
if ((v = xs_dict_get(srv_config, "disable_cache")) && xs_type(v) == XSTYPE_TRUE)
|
||||||
|
cache = 0;
|
||||||
|
|
||||||
p_path = xs_list_get(l, 2);
|
p_path = xs_list_get(l, 2);
|
||||||
|
|
||||||
if (p_path == NULL) {
|
if (p_path == NULL) {
|
||||||
/* public timeline */
|
/* public timeline */
|
||||||
xs *h = xs_str_localtime(0, "%Y-%m.html");
|
xs *h = xs_str_localtime(0, "%Y-%m.html");
|
||||||
|
|
||||||
if (history_mtime(&snac, h) > timeline_mtime(&snac)) {
|
if (cache && history_mtime(&snac, h) > timeline_mtime(&snac)) {
|
||||||
snac_debug(&snac, 1, xs_fmt("serving cached local timeline"));
|
snac_debug(&snac, 1, xs_fmt("serving cached local timeline"));
|
||||||
|
|
||||||
*body = history_get(&snac, h);
|
*body = history_get(&snac, h);
|
||||||
|
@ -748,7 +754,7 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
|
||||||
if (!login(&snac, req))
|
if (!login(&snac, req))
|
||||||
status = 401;
|
status = 401;
|
||||||
else {
|
else {
|
||||||
if (history_mtime(&snac, "timeline.html_") > timeline_mtime(&snac)) {
|
if (cache && history_mtime(&snac, "timeline.html_") > timeline_mtime(&snac)) {
|
||||||
snac_debug(&snac, 1, xs_fmt("serving cached timeline"));
|
snac_debug(&snac, 1, xs_fmt("serving cached timeline"));
|
||||||
|
|
||||||
*body = history_get(&snac, "timeline.html_");
|
*body = history_get(&snac, "timeline.html_");
|
||||||
|
|
Loading…
Reference in a new issue