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

simplify cache config by letting upstream define headers, refs #20420

parent 91a6cc29
No related branches found
No related tags found
No related merge requests found
...@@ -14,55 +14,18 @@ server { ...@@ -14,55 +14,18 @@ server {
} }
location /streaming/ { location /streaming/ {
# Live # Live; expiration headers are defined by upstream (nginx/wowza)
location ~ \.m3u8$ { rewrite ^/(.*)$ /$1? break;
rewrite ^/(.*)$ /$1? break; proxy_pass {{ source_server }};
proxy_pass {{ source_server }}; proxy_cache uc-cache;
proxy_cache uc-cache; # do not consider secure urls as new files
# do not consider secure urls as new files proxy_cache_key $scheme$proxy_host$uri;
proxy_cache_key $scheme$proxy_host$uri; # only one request at a time will be allowed to populate a new cache element
# only one request at a time will be allowed to populate a new cache element proxy_cache_lock on;
proxy_cache_lock on; # hide upstream X-Cache header
# serve from cache while updating proxy_hide_header X-Cache;
proxy_cache_use_stale updating; # add own X-Cache header
# ignore upstream headers add_header X-Cache $upstream_cache_status;
# http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_valid
proxy_ignore_headers "Cache-Control" "X-Accel-Expires" "Expires";
# 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;
proxy_pass {{ source_server }};
proxy_cache uc-cache;
# 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;
# serve from cache while updating
proxy_cache_use_stale updating;
# ignore upstream headers
# http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_valid
proxy_ignore_headers "Cache-Control" "X-Accel-Expires" "Expires";
# 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/ { location /resources/ {
# VOD # VOD
......
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