Skip to content

Commit cf4517c

Browse files
authored
cache current hour previews (#11606)
1 parent 61f79af commit cf4517c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

frigate/api/media.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ def preview_gif(camera_name: str, start_ts, end_ts, max_cache_age=2592000):
12321232

12331233
@MediaBp.route("/<camera_name>/start/<int:start_ts>/end/<int:end_ts>/preview.mp4")
12341234
@MediaBp.route("/<camera_name>/start/<float:start_ts>/end/<float:end_ts>/preview.mp4")
1235-
def preview_mp4(camera_name: str, start_ts, end_ts):
1235+
def preview_mp4(camera_name: str, start_ts, end_ts, max_cache_age=2592000):
12361236
file_name = f"clip_{camera_name}_{start_ts}-{end_ts}.mp4"
12371237

12381238
if len(file_name) > 1000:
@@ -1380,7 +1380,7 @@ def preview_mp4(camera_name: str, start_ts, end_ts):
13801380

13811381
response = make_response()
13821382
response.headers["Content-Description"] = "File Transfer"
1383-
response.headers["Cache-Control"] = "no-cache"
1383+
response.headers["Cache-Control"] = f"private, max-age={max_cache_age}"
13841384
response.headers["Content-Type"] = "video/mp4"
13851385
response.headers["Content-Length"] = os.path.getsize(path)
13861386
response.headers["X-Accel-Redirect"] = (

0 commit comments

Comments
 (0)