frigate icon indicating copy to clipboard operation
frigate copied to clipboard

[Bug]: /camera_name/label/snapshot.jpg has incorrect cache max-age

Open lawm opened this issue 1 year ago • 3 comments

Describe the problem you are having

I expect /camera_name/label/snapshot.jpg to give me the latest snapshot of the specified label.

If the event is ongoing, it returns a snapshot with Cache-Control=no-store. If the event is complete, it returns a snapshot with Cache-Control=private, max-age=31536000

If there is a new event, /camera_name/label/snapshot.jpg still returns the old event snapshot because of the cache setting.

Related endpoint /camera_name/label/thumbnail.jpg always returns max-age=60.

Potential fix 1: make both of the above always return Cache-Control=no-store Potential fix 2: make snapshot.jpg to return max-age=60 if the event is complete, matching the current thumbnail behavior: pull request #9812

Version

latest commit b9e20fc

Frigate config file

-

Relevant log output

-

FFprobe output from your camera

-

Frigate stats

No response

Operating system

Debian

Install method

Docker Compose

Coral version

CPU (no coral)

Network connection

Wired

Camera make and model

Any other information that may be helpful

No response

lawm avatar Feb 11 '24 22:02 lawm

It seems like you're looking at the wrong function. The label based snapshot doesn't have cache control https://github.com/blakeblackshear/frigate/blob/dev/frigate%2Fhttp.py#L1051

NickM-27 avatar Feb 11 '24 22:02 NickM-27

Actually, I see what you're saying about when the event is ended only

NickM-27 avatar Feb 11 '24 22:02 NickM-27

it does.


@bp.route("/<camera_name>/<label>/snapshot.jpg")
def label_snapshot(camera_name, label):
...
    return event_snapshot(event.id)

event_snapshot() has the Cache-Control behavior in origin post

edit: saw your comment as I was writing this

lawm avatar Feb 11 '24 22:02 lawm

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Mar 13 '24 00:03 github-actions[bot]