Cache static Gerrit contents
Needs testing!
Currently needs a `location` override because Gerrit sometimes
spuriously sets `Cache-Control: private`.
diff --git a/nginx/sa.conf b/nginx/sa.conf
index 6d2105f..65f7a7a 100644
--- a/nginx/sa.conf
+++ b/nginx/sa.conf
@@ -1,3 +1,5 @@
+proxy_cache_path /var/cache/nginx/gerrit levels=2 keys_zone=GERRIT:1m inactive=1w max_size=16m;
+
server {
listen 80;
listen [::]:80;
@@ -59,5 +61,16 @@
proxy_pass http://gerrit:8080;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
+
+ location ~ ^/(bower_components|elements|fonts|styles)/ {
+ proxy_pass http://gerrit:8080;
+ proxy_set_header X-Forwarded-For $remote_addr;
+ proxy_set_header Host $host;
+ proxy_cache GERRIT;
+ proxy_cache_valid 200 1h;
+ proxy_cache_use_stale error timeout invalid_header updating http_500 http_503;
+ # Gerrit bug sets `private`, hence the whole location override:
+ proxy_ignore_headers Cache-Control;
+ }
}
}