Skip to content

Commit 9d34ce1

Browse files
committed
feat: add legacy fastcgi cache
1 parent 9ebb15c commit 9d34ce1

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ libretime_api_systemd_override:
5151
########################################################################################
5252
libretime_legacy_managed: true
5353
libretime_legacy_web_root: /usr/share/libretime/legacy
54+
libretime_legacy_cache_paths: []
5455

5556
# > Postgresql
5657
########################################################################################

templates/nginx/libretime.conf.j2

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
{% if libretime_legacy_cache_paths -%}
2+
fastcgi_cache_path /var/lib/nginx/cache levels=1:2 keys_zone=legacy:100m;
3+
fastcgi_cache_key "$request_method$scheme$host$request_uri";
4+
5+
map $request_uri $no_cache {
6+
default "1";
7+
{% for path in libretime_legacy_cache_paths %}
8+
"{{ path }}" "0";
9+
{% endfor %}
10+
}
11+
12+
{% endif -%}
13+
114
server {
215
listen {{ libretime_listen_port }};
316
listen [::]:{{ libretime_listen_port }};
@@ -21,13 +34,20 @@ server {
2134
# try_files $uri =404;
2235
try_files $fastcgi_script_name =404;
2336

24-
include fastcgi_params;
25-
2637
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
2738
set $path_info $fastcgi_path_info;
2839
fastcgi_param PATH_INFO $path_info;
2940
include fastcgi_params;
3041

42+
{% if libretime_legacy_cache_paths -%}
43+
fastcgi_cache legacy;
44+
fastcgi_cache_valid 200 5s;
45+
46+
fastcgi_no_cache $no_cache;
47+
fastcgi_cache_bypass $no_cache;
48+
49+
{% endif -%}
50+
3151
fastcgi_index index.php;
3252
fastcgi_pass unix:/run/libretime-legacy.sock;
3353
}

0 commit comments

Comments
 (0)