optimize caching of image data from api

This commit is contained in:
Blake Blackshear
2022-04-25 08:00:01 -05:00
parent bc0206de9d
commit 91539de3ff
2 changed files with 30 additions and 5 deletions

View File

@@ -81,11 +81,13 @@ http {
add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range';
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
add_header Access-Control-Allow-Origin '*';
expires -1;
add_header Cache-Control "no-store";
expires off;
}
location /stream/ {
add_header 'Cache-Control' 'no-cache';
add_header Cache-Control "no-store";
expires off;
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Expose-Headers' 'Content-Length';
@@ -170,7 +172,20 @@ http {
proxy_set_header Host $host;
}
location ~* /api/(.*\.(jpg|jpeg|png)$) {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
proxy_pass http://frigate_api/$1;
proxy_pass_request_headers on;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api/ {
add_header Cache-Control "no-store";
expires off;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
proxy_pass http://frigate_api/;
@@ -180,11 +195,11 @@ http {
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
add_header Cache-Control "no-cache";
add_header Cache-Control "no-store";
expires off;
location ~* \.(?:js|css|svg|ico|png)$ {
location /assets/ {
access_log off;
expires 1y;
add_header Cache-Control "public";