Nginx - architecture articles nginx in slices

slice

Function : The range protocol large file into multiple small files, cache is better with customers range service agreement

location / {
    slice             1m;
    proxy_cache       cache;
    proxy_cache_key   $uri$is_args$args$slice_range;
    proxy_set_header  Range $slice_range;
    proxy_cache_valid 200 206 1h;
    proxy_pass        http://localhost:8000;
}

Advantages :

1, can break or nginx php upload size limit, the theory can upload unlimited data (theoretically depending on hard disk size).

2, or asynchronous threads may be used to improve the upload speed upload, may be used in javascript xmlhttprequest asynchronous upload, may be used for concurrent coroutine library GuzzleHttp upload in PHP, other languages ​​may also be used in multi-threaded upload, may also be open multiple browser upload, multiple colleagues can be a pass.

3, disconnection retransmission, if the upload process, a network outage, when the network can be restored to the unit block size, retransmission has successfully uploaded fragments do not need to upload.

File descriptor cache open_file_cache

Configuration can cache static files meta information, when these static file is accessed frequently can significantly improve performance

location / {
	open_file_cache max=64 inactive=30d;
	open_file_cache_min_uses 8;
	open_file_cache_valid 3m;
}

note:

max = 64 indicates the maximum number of cache files provided after this number exceeds the discard cold Nginx LRU data in principle.

inactive = 30d and open_file_cache_min_uses 8 indicate if less than eight times in 30 days, the number of times a file is accessed, then it will be removed from the cache.

open_file_cache_valid 3m indicating whether the file meta-information once every 3 minutes to check the cache is up to date, if not the updates.

HTTP2 push resources

location /test {
	add_header link "";
	http2_push_preload on;
}

Function: Client Push resources

Published 98 original articles · won praise 185 · views 90000 +

Guess you like

Origin blog.csdn.net/xuezhiwu001/article/details/102647581