Spaces:
Running
Running
JOHN SILLVESTOR commited on
Faster first bytes: 512KiB GetFile, no stream warm steal, skip duration wait
Browse files
server.js
CHANGED
|
@@ -17,7 +17,7 @@ const TOKEN_TTL = 900;
|
|
| 17 |
const MIN_ALIGN = 4096;
|
| 18 |
const MB = 1024 * 1024;
|
| 19 |
const GET_SIZES = [524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096];
|
| 20 |
-
const FIRST_GET =
|
| 21 |
const HOT_HEAD = 524288;
|
| 22 |
const HOT_TAIL = 1048576;
|
| 23 |
const BOT_MAX = 24;
|
|
@@ -987,10 +987,6 @@ async function handleGenerate(req, res, url) {
|
|
| 987 |
const cachedDur = durCache.get(String(msgId));
|
| 988 |
if (cachedDur > 1) rec.duration = cachedDur;
|
| 989 |
warmHot(bot, rec, msgId).catch(function () {});
|
| 990 |
-
if (!(rec.duration > 1)) {
|
| 991 |
-
const d = await withTime(fillDuration(bot, rec, msgId), 400, 0);
|
| 992 |
-
if (d > 1) rec.duration = d;
|
| 993 |
-
}
|
| 994 |
const playMime = httpVideoType(rec.mime, rec.name);
|
| 995 |
const exp = Math.floor(Date.now() / 1000) + TOKEN_TTL;
|
| 996 |
const k = sealTicket({ m: msgId, h: hash, u: uid || "anon", l: lvl, b: bot.idx, e: exp, s: rec.size, n: playMime, p: ipTag(ip) });
|
|
@@ -1067,7 +1063,6 @@ async function handleStream(req, res, url, msgId) {
|
|
| 1067 |
return res.end();
|
| 1068 |
}
|
| 1069 |
const size = rec.size;
|
| 1070 |
-
warmHot(bot, rec, msgId).catch(function () {});
|
| 1071 |
const rng = parseRange(req.headers.range, size);
|
| 1072 |
const ranged = !!req.headers.range;
|
| 1073 |
const headers = {
|
|
|
|
| 17 |
const MIN_ALIGN = 4096;
|
| 18 |
const MB = 1024 * 1024;
|
| 19 |
const GET_SIZES = [524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096];
|
| 20 |
+
const FIRST_GET = 524288;
|
| 21 |
const HOT_HEAD = 524288;
|
| 22 |
const HOT_TAIL = 1048576;
|
| 23 |
const BOT_MAX = 24;
|
|
|
|
| 987 |
const cachedDur = durCache.get(String(msgId));
|
| 988 |
if (cachedDur > 1) rec.duration = cachedDur;
|
| 989 |
warmHot(bot, rec, msgId).catch(function () {});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 990 |
const playMime = httpVideoType(rec.mime, rec.name);
|
| 991 |
const exp = Math.floor(Date.now() / 1000) + TOKEN_TTL;
|
| 992 |
const k = sealTicket({ m: msgId, h: hash, u: uid || "anon", l: lvl, b: bot.idx, e: exp, s: rec.size, n: playMime, p: ipTag(ip) });
|
|
|
|
| 1063 |
return res.end();
|
| 1064 |
}
|
| 1065 |
const size = rec.size;
|
|
|
|
| 1066 |
const rng = parseRange(req.headers.range, size);
|
| 1067 |
const ranged = !!req.headers.range;
|
| 1068 |
const headers = {
|