-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create
nowplaying/albumart
rate limiter based on current song (#249)
PR creates a new rate limiter that will slow down requests on the `/api/nowplaying/albumart` API. This API serves relatively large file image, so it's necessary to have a rate limiter mostly for the sake of data transfer volume. This works based on current song playing. When a new song starts, a client under a single IP can request the song's album art up to **16 times over the _duration_ of the entire song**. 16 was arbitrarily selected as an amount I expect most people to be able to comfortably pull album art under normal radio usage. We'll adjust or consider parameterizing this if necessary. If the client hits the limit before the current song ends they will receive a `304` error to indicate that Cadence will not be re-transmitting the art anymore, though the album art is still the same and it is safe to use whatever it last sent. When the current song ends, the database tracking the artwork request count is flushed and all clients reset their allowed usage of the API.
- Loading branch information
Showing
4 changed files
with
73 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters