Increase cache validity period in nginx.conf

This revised nginx.conf holds the cache for one week, truly.  For some reason there are
two tuning knobs required to make one adjustment (cache duration).  Without this fix the
cache was only held for 10 minutes.  The most important change is the "inactive=1w" which
as I implied, is the *second* reference to one week.  Sorry for this oversight.

Nginx can be run on something as simple as a raspberry PI.  I run it on a network file
server attached to my desktop via copper ethernet.  By caching the footprint libraries
from github, I can load all github libraries in about 2.5 seconds, making github the
fastest plugin of any kind.
This commit is contained in:
Dick Hollenbeck 2016-06-29 12:25:28 +02:00 committed by Maciej Suminski
parent fde12ebd25
commit 5fa8aa3660
1 changed files with 8 additions and 4 deletions

View File

@ -6,7 +6,7 @@
# In my case I also added a small RAM disk on a linux server to hold the cache. # In my case I also added a small RAM disk on a linux server to hold the cache.
# This line in /etc/fstab adds my RAM disk, this is 10 mbytes but 5mb would # This line in /etc/fstab adds my RAM disk, this is 10 mbytes but 5mb would
# probably suffice: # probably suffice:
none /var/cache/nginx tmpfs size=10m # none /var/cache/nginx tmpfs size=10m
# I then set my KIGITHUB environment variable to # I then set my KIGITHUB environment variable to
# export KIGITHUB=http://my_server:54321/KiCad # export KIGITHUB=http://my_server:54321/KiCad
@ -28,7 +28,7 @@ events {
http { http {
proxy_cache_path /var/cache/nginx keys_zone=cache_zone:10m; proxy_cache_path /var/cache/nginx keys_zone=cache_zone:10m inactive=1w;
server { server {
# nginx will listen on this port: # nginx will listen on this port:
@ -38,7 +38,7 @@ http {
# hold the stuff for one week, then mark it as out of date which will # hold the stuff for one week, then mark it as out of date which will
# cause it to be reloaded from github. # cause it to be reloaded from github.
proxy_cache_valid 1w; proxy_cache_valid any 1w;
location /KiCad/ { location /KiCad/ {
rewrite /KiCad/(.+) /KiCad/$1/zip/master break; rewrite /KiCad/(.+) /KiCad/$1/zip/master break;
@ -46,6 +46,9 @@ http {
# Skip past the redirect issued by https://github.com # Skip past the redirect issued by https://github.com
proxy_pass https://codeload.github.com; proxy_pass https://codeload.github.com;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_cache_lock on;
proxy_set_header Proxy-Connection "Keep-Alive"; proxy_set_header Proxy-Connection "Keep-Alive";
proxy_ignore_headers "Set-Cookie"; proxy_ignore_headers "Set-Cookie";
@ -62,3 +65,4 @@ http {
} }
} }
} }