@@ -18,7 +18,13 @@ http {
18
18
default_type application/octet-stream;
19
19
sendfile on ;
20
20
keepalive_timeout 65 ;
21
- proxy_cache_path /tmp/npm-cache levels=1:2 keys_zone=STATIC:10m inactive=24h max_size=1g;
21
+ proxy_cache_path /tmp/npm/cache levels=1:2 keys_zone=NPM:10m inactive=90d max_size=5g;
22
+ proxy_temp_path /tmp/npm/temp;
23
+ proxy_cache_lock on;
24
+ log_format upstreamlog '$remote_addr - $remote_user [$time_local ] '
25
+ '"$request " $status $body_bytes_sent '
26
+ '"$http_referer " "$http_user_agent " "$upstream_cache_status "' ;
27
+ access_log logs/access.log upstreamlog;
22
28
server {
23
29
listen 4873 ;
24
30
set $npm_config_registry '' ;
@@ -38,16 +44,23 @@ http {
38
44
location ~ ^/.*\.tgz$ {
39
45
resolver 127.0.0.1 ipv6=off;
40
46
proxy_pass $npm_config_registry ;
41
- proxy_cache STATIC;
42
- proxy_cache_valid 200 1d;
47
+ proxy_cache NPM;
48
+ proxy_ignore_headers X-Accel-Redirect X-Accel-Expires X-Accel-Limit-Rate X-Accel-Buffering X-Accel-Charset Expires Cache-Control Set-Cookie Vary;
49
+ # npm package tarballs are NEVER supposed to change
50
+ proxy_cache_revalidate off;
51
+ proxy_cache_valid 200 90d;
43
52
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
44
53
}
45
54
location / {
46
55
resolver 127.0.0.1 ipv6=off;
47
56
proxy_pass $npm_config_registry ;
48
57
proxy_buffers 32 1m;
49
- proxy_cache STATIC;
50
- proxy_cache_valid 200 1d;
58
+ proxy_cache NPM;
59
+ # need nginx-1.11.10 for this, which isn' t in openresty yet:
60
+ # proxy_cache_background_update on;
61
+ proxy_cache_revalidate on;
62
+ # let our metadata be 20 minutes old, at most
63
+ proxy_cache_valid 200 20m ;
51
64
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
52
65
# need to disable encoding in order to be able to filter the response body
53
66
proxy_set_header Accept-Encoding "" ;
0 commit comments