From cf4517cbdbc58237bb9a51109ac30b052ae1c99c Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 28 May 2024 16:35:55 -0600 Subject: [PATCH] cache current hour previews (#11606) --- frigate/api/media.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frigate/api/media.py b/frigate/api/media.py index d493b6fa9..21abe0591 100644 --- a/frigate/api/media.py +++ b/frigate/api/media.py @@ -1232,7 +1232,7 @@ def preview_gif(camera_name: str, start_ts, end_ts, max_cache_age=2592000): @MediaBp.route("//start//end//preview.mp4") @MediaBp.route("//start//end//preview.mp4") -def preview_mp4(camera_name: str, start_ts, end_ts): +def preview_mp4(camera_name: str, start_ts, end_ts, max_cache_age=2592000): file_name = f"clip_{camera_name}_{start_ts}-{end_ts}.mp4" if len(file_name) > 1000: @@ -1380,7 +1380,7 @@ def preview_mp4(camera_name: str, start_ts, end_ts): response = make_response() response.headers["Content-Description"] = "File Transfer" - response.headers["Cache-Control"] = "no-cache" + response.headers["Cache-Control"] = f"private, max-age={max_cache_age}" response.headers["Content-Type"] = "video/mp4" response.headers["Content-Length"] = os.path.getsize(path) response.headers["X-Accel-Redirect"] = (