File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 # DNS resolver for proxy_pass
1313 resolver 9.9.9.9 valid=30s;
1414
15+ # Proxy cache in /dev/shm (tmpfs, persists across dyno restarts)
16+ proxy_cache_path /dev/shm/nginx_cache levels=1:2 keys_zone=plausible_cache:1m max_size=100m inactive=5m use_temp_path=off;
17+
1518 # Security headers
1619 add_header X-Frame-Options "SAMEORIGIN" always;
1720 add_header X-Content-Type-Options "nosniff" always;
@@ -39,11 +42,17 @@ http {
3942 set $plausible_script_url https://plausible.io/js/pa-PFruVsE_br97UUCRXE_6f.js;
4043 set $plausible_event_url https://plausible.io/api/event;
4144
42- # Plausible: Proxy script.js
45+ # Plausible: Proxy script.js (cached)
4346 location = /js/script.js {
47+ proxy_cache plausible_cache;
48+ proxy_cache_valid 200 5m;
49+ proxy_cache_key "$host$uri";
4450 proxy_pass $plausible_script_url;
4551 proxy_set_header Host plausible.io;
4652 proxy_buffering on;
53+
54+ # Cache response headers
55+ add_header X-Cache $upstream_cache_status;
4756 }
4857
4958 # Plausible: Proxy event API
You can’t perform that action at this time.
0 commit comments