diff options
| author | 2022-10-09 17:54:01 +0200 | |
|---|---|---|
| committer | 2022-10-09 17:54:01 +0200 | |
| commit | 305591ae311af92c36d779f255849764f5f20f55 (patch) | |
| tree | 60429c90299d968a544f2317657e8990d74b44df | |
| parent | Fail in bad disk layout version. (diff) | |
| download | penes-snac2-305591ae311af92c36d779f255849764f5f20f55.tar.gz penes-snac2-305591ae311af92c36d779f255849764f5f20f55.tar.xz penes-snac2-305591ae311af92c36d779f255849764f5f20f55.zip | |
New optional server config directive 'disable_cache'.
| -rw-r--r-- | html.c | 10 |
1 files changed, 8 insertions, 2 deletions
| @@ -708,6 +708,8 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char * | |||
| 708 | int status = 404; | 708 | int status = 404; |
| 709 | snac snac; | 709 | snac snac; |
| 710 | char *uid, *p_path; | 710 | char *uid, *p_path; |
| 711 | int cache = 1; | ||
| 712 | char *v; | ||
| 711 | 713 | ||
| 712 | xs *l = xs_split_n(q_path, "/", 2); | 714 | xs *l = xs_split_n(q_path, "/", 2); |
| 713 | 715 | ||
| @@ -718,13 +720,17 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char * | |||
| 718 | return 404; | 720 | return 404; |
| 719 | } | 721 | } |
| 720 | 722 | ||
| 723 | /* check if server config variable 'disable_cache' is set */ | ||
| 724 | if ((v = xs_dict_get(srv_config, "disable_cache")) && xs_type(v) == XSTYPE_TRUE) | ||
| 725 | cache = 0; | ||
| 726 | |||
| 721 | p_path = xs_list_get(l, 2); | 727 | p_path = xs_list_get(l, 2); |
| 722 | 728 | ||
| 723 | if (p_path == NULL) { | 729 | if (p_path == NULL) { |
| 724 | /* public timeline */ | 730 | /* public timeline */ |
| 725 | xs *h = xs_str_localtime(0, "%Y-%m.html"); | 731 | xs *h = xs_str_localtime(0, "%Y-%m.html"); |
| 726 | 732 | ||
| 727 | if (history_mtime(&snac, h) > timeline_mtime(&snac)) { | 733 | if (cache && history_mtime(&snac, h) > timeline_mtime(&snac)) { |
| 728 | snac_debug(&snac, 1, xs_fmt("serving cached local timeline")); | 734 | snac_debug(&snac, 1, xs_fmt("serving cached local timeline")); |
| 729 | 735 | ||
| 730 | *body = history_get(&snac, h); | 736 | *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 * | |||
| 748 | if (!login(&snac, req)) | 754 | if (!login(&snac, req)) |
| 749 | status = 401; | 755 | status = 401; |
| 750 | else { | 756 | else { |
| 751 | if (history_mtime(&snac, "timeline.html_") > timeline_mtime(&snac)) { | 757 | if (cache && history_mtime(&snac, "timeline.html_") > timeline_mtime(&snac)) { |
| 752 | snac_debug(&snac, 1, xs_fmt("serving cached timeline")); | 758 | snac_debug(&snac, 1, xs_fmt("serving cached timeline")); |
| 753 | 759 | ||
| 754 | *body = history_get(&snac, "timeline.html_"); | 760 | *body = history_get(&snac, "timeline.html_"); |