I recently noticed that the Invidious video cache that is stored in the database to prevent fetching the video again in again from Innertube limited /player endpoint makes Invidious re-fetch the video if it has been clicked a user within those 10 minutes.
|
(Time.utc - video.updated > 10.minutes) || |
I think this value for the cache was in place to keep the video information updated in case there was any changes back when the Innertube /player endpoint wasn't limited, but since we are now rate limited, this value would be better to sit at 6 hours (which is the current expiration time of the video stream since the video was requested) or we can calculate it from the expire query parameter in videoplayback requests. Or we can just remove this check and rely on:
|
def delete_expired |
|
request = <<-SQL |
|
DELETE FROM nonces * |
|
WHERE expire < now() |
|
SQL |
|
|
|
PG_DB.exec(request) |
|
end |
with it's job to remove the expired (or ones that are going to expire) videos from cache:
|
begin |
|
Invidious::Database::Videos.delete_expired |
|
Invidious::Database::Nonces.delete_expired |
|
rescue DB::Error |
|
failed = true |
|
end |
|
|
|
# Retry earlier than scheduled on DB error |
|
if failed |
|
LOGGER.info("jobs: ClearExpiredItems failed. Retrying in 10 minutes.") |
|
sleep 10.minutes |
|
else |
|
LOGGER.info("jobs: ClearExpiredItems done.") |
|
sleep 1.hour |
|
end |
I recently noticed that the Invidious video cache that is stored in the database to prevent fetching the video again in again from Innertube limited
/playerendpoint makes Invidious re-fetch the video if it has been clicked a user within those 10 minutes.invidious/src/invidious/videos.cr
Line 302 in e7f8b15
I think this value for the cache was in place to keep the video information updated in case there was any changes back when the Innertube
/playerendpoint wasn't limited, but since we are now rate limited, this value would be better to sit at 6 hours (which is the current expiration time of the video stream since the video was requested) or we can calculate it from theexpirequery parameter in videoplayback requests. Or we can just remove this check and rely on:invidious/src/invidious/database/nonces.cr
Lines 20 to 27 in e7f8b15
with it's job to remove the expired (or ones that are going to expire) videos from cache:
invidious/src/invidious/jobs/clear_expired_items_job.cr
Lines 10 to 24 in e7f8b15