From 56dfc9f992a712dd45a68538596e27b70c75bb37 Mon Sep 17 00:00:00 2001
From: mickamy <t.mikami1992@gmail.com>
Date: Tue, 2 Jan 2024 18:24:54 +0900
Subject: [PATCH] more cache on nginx

---
 admin/config/nginx.conf  | 17 +++++++++++++----
 docker/app/entrypoint.sh |  3 ++-
 note.md                  |  6 ++++++
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/admin/config/nginx.conf b/admin/config/nginx.conf
index 848224e1..46b9af8d 100644
--- a/admin/config/nginx.conf
+++ b/admin/config/nginx.conf
@@ -21,7 +21,8 @@ http {
 
   # cache の設定
   proxy_cache_path /var/nginx/cache_1 levels=1:2 keys_zone=political_parties_cache:1m max_size=1g inactive=1m use_temp_path=on;
-  proxy_cache_path /var/nginx/cache_2 levels=1:2 keys_zone=candidates_cache:1m max_size=1g inactive=1m use_temp_path=on;
+  proxy_cache_path var/nginx/cache_2 levels=1:2 keys_zone=candidates_cache:1m max_size=1g inactive=1m use_temp_path=on;
+  proxy_cache_path var/nginx/cache_3 levels=1:2 keys_zone=index_cache:1m max_size=1g inactive=1m use_temp_path=on;
   
   server {
     listen 443;
@@ -38,15 +39,23 @@ http {
 
     location /political_parties/ {
       proxy_cache political_parties_cache;
-      proxy_cache_valid 200 302 1m;
+      proxy_cache_valid 200 302 30s;
       proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
       proxy_set_header Host $host;
       proxy_pass http://app;
-    }
+		}
 
     location /candidates/ {
       proxy_cache candidates_cache;
-      proxy_cache_valid 200 302 1m;
+      proxy_cache_valid 200 302 30s;
+      proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
+      proxy_set_header Host $host;
+      proxy_pass http://app;
+    }
+
+    location = / {
+      proxy_cache index_cache;
+      proxy_cache_valid 200 302 30s;
       proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
       proxy_set_header Host $host;
       proxy_pass http://app;
diff --git a/docker/app/entrypoint.sh b/docker/app/entrypoint.sh
index a23c0bc7..dddfe704 100755
--- a/docker/app/entrypoint.sh
+++ b/docker/app/entrypoint.sh
@@ -1,6 +1,7 @@
 #!/bin/bash -eux
 
-sudo mkdir -p /var/nginx/cache_1 /var/nginx/cache_2
+sudo mkdir -p /usr/share/nginx/var/nginx/cache_1 /usr/share/nginx/var/nginx/cache_2 /usr/share/nginx/var/nginx/cache_3 /usr/share/nginx/var/nginx/cache_4 /usr/share/nginx/var/nginx/cache_5
+sudo mkdir -p /var/nginx/cache_1 /var/nginx/cache_2 /var/nginx/cache_3 /var/nginx/cache_4 /var/nginx/cache_5
 sudo nginx -t
 sudo service nginx start
 sudo service mysql start || true
diff --git a/note.md b/note.md
index 35dd4221..cce862af 100644
--- a/note.md
+++ b/note.md
@@ -483,3 +483,9 @@ docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443 --workload 6"
 2024/01/02 09:12:13 {"score": 18968, "success": 16184, "failure": 0}
 ```
 
+- more cache on nginx 
+
+```
+
+```
+