Skip to content
Snippets Groups Projects
Commit 773b0736 authored by Florent Thiery's avatar Florent Thiery
Browse files

optimize cache conf, fixes #20420

parent 2ce5d4e6
No related branches found
No related tags found
No related merge requests found
......@@ -23,19 +23,21 @@ server {
proxy_cache_key $scheme$proxy_host$uri;
# only one request at a time will be allowed to populate a new cache element
proxy_cache_lock on;
proxy_cache_min_uses 1;
proxy_cache_use_stale updating;
# how long should the data be kept in the cache
proxy_cache_valid 200 1s;
# instruct browser never to cache this
expires -1;
# headers
# ignore upstream headers
# http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_valid
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Set-Cookie;
proxy_ignore_headers X-Accel-Expires;
proxy_ignore_headers Expires;
proxy_hide_header Pragma;
# hide upstream X-Cache header
proxy_hide_header X-Cache;
# add own X-Cache header
add_header X-Cache $upstream_cache_status;
# m3u8-specific
# how long should the data be kept in this cache
proxy_cache_valid 200 2s;
# instruct browsers never to cache m3u8
expires -1;
}
location ~ \.ts$ {
rewrite ^/(.*)$ /$1? break;
......@@ -45,19 +47,21 @@ server {
proxy_cache_key $scheme$proxy_host$uri;
# only one request at a time will be allowed to populate a new cache element
proxy_cache_lock on;
proxy_cache_min_uses 1;
proxy_cache_use_stale updating;
# how long should the data be kept in the cache
proxy_cache_valid 200 10s;
# instruct browser to cache this
expires 2s;
# headers
# ignore upstream headers
# http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_valid
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Set-Cookie;
proxy_ignore_headers X-Accel-Expires;
proxy_ignore_headers Expires;
proxy_hide_header Pragma;
# hide upstream X-Cache header
proxy_hide_header X-Cache;
# add own X-Cache header
add_header X-Cache $upstream_cache_status;
# ts-specific
# how long should the data be kept in this cache
proxy_cache_valid 200 10s;
# instruct browsers to cache this for 6s
expires 6s;
}
}
location /resources/ {
......@@ -81,7 +85,6 @@ server {
proxy_ignore_headers Set-Cookie;
proxy_ignore_headers X-Accel-Expires;
proxy_ignore_headers Expires;
proxy_hide_header Pragma;
add_header X-Cache $upstream_cache_status;
}
}
......
......@@ -55,28 +55,16 @@ server {
}
}
location /streaming/ {
location ~ \.m3u8$ {
rewrite ^/streaming/(.*)$ /live/$1? break;
proxy_pass http://localhost:1935;
proxy_cache livecache;
proxy_cache_key $scheme$proxy_host$uri;
proxy_cache_lock on;
proxy_cache_min_uses 1;
proxy_cache_use_stale updating;
proxy_cache_valid 200 1s;
}
location ~ \.ts$ {
rewrite ^/streaming/(.*)$ /live/$1? break;
proxy_pass http://localhost:1935;
proxy_cache livecache;
proxy_cache_key $scheme$proxy_host$uri;
proxy_cache_lock on;
proxy_cache_min_uses 1;
proxy_cache_valid 200 10s;
}
# only urls to ts and m3u8 files are allowed, discard any requested path for other urls
rewrite ^/streaming/(.*)$ /live/? break;
proxy_pass http://localhost:1935/live/;
rewrite ^/streaming/(.*)$ /live/$1? break;
proxy_pass http://localhost:1935;
proxy_cache livecache;
# do not consider secure urls as new files
proxy_cache_key $scheme$proxy_host$uri;
# only one request at a time will be allowed to populate a new cache element
proxy_cache_lock on;
# show if playlist or fragment has been cached from wowza
add_header X-Cache $upstream_cache_status;
# wowza is defining expiration headers (m3u8 is 1s, ts is 3600)
}
location / {
uwsgi_pass unix:///home/msuser/mstmp/uwsgi.sock;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment