PERF: cache static assets in NGINX for longer

Previously our cache would expire any asset that was not accessed for 10
minutes. This is way too short and was never intended. All the assets we
are serving are usually very long living assets like avatars and css files

1 day is a reasonable setting here cause it offers far better protection.
I would consider upping this to a week though longer term.

Maximum disk space of cache was increased as well to 600m. Very unlikely to
ever hit this except on very large sites.

Additionally, this places all the cached assets in nested directories, we
never want cached files to be in one giant directory cause it is inefficient
This commit is contained in:
Sam Saffron 2019-11-07 12:12:24 +11:00
parent ee5b56914c
commit 1d1dd2a4d4

View File

@ -10,7 +10,10 @@ upstream discourse {
server unix:/var/www/discourse/tmp/sockets/thin.3.sock;
}
proxy_cache_path /var/nginx/cache keys_zone=one:10m max_size=200m;
# inactive means we keep stuff around for 1440m minutes regardless of last access (1 week)
# levels means it is a 2 deep heirarchy cause we can have lots of files
# max_size limits the size of the cache
proxy_cache_path /var/nginx/cache inactive=1440m levels=1:2 keys_zone=one:10m max_size=600m;
# see: https://meta.discourse.org/t/x/74060
proxy_buffer_size 8k;