Cache busting

This commit is contained in:
soruly 2022-06-20 15:02:09 +00:00
parent cef1b6f5aa
commit 0bc52a836a
No known key found for this signature in database
GPG Key ID: EF971E90F3D2521F
4 changed files with 16 additions and 8 deletions

View File

@ -153,7 +153,10 @@ app.get("/register", rateLimit({ max: 5, windowMs: 60 * 1000 }), getRegister);
app.post("/register", rateLimit({ max: 5, windowMs: 60 * 1000 }), postRegister);
app.get("/reg", async (req, res) => {
if (ENABLE_FIDO2 && ALLOW_REGISTER) return res.render("register");
if (ENABLE_FIDO2 && ALLOW_REGISTER)
return res.render("register", {
modifiedJS: Math.floor(fs.statSync("./static/register.js").mtimeMs).toString(36),
});
return res.status(403).send("Registration disabled");
});
@ -179,7 +182,10 @@ app.get("/", async (req, res) => {
.map((e) => e.replace(".json", ""))
.includes(req.cookies.session)
) {
return res.render("login", { ALLOW_REGISTER });
return res.render("login", {
modifiedJS: Math.floor(fs.statSync("./static/login.js").mtimeMs).toString(36),
ALLOW_REGISTER,
});
}
if (req.headers.accept?.toLowerCase() === "text/event-stream") {
@ -213,6 +219,8 @@ app.get("/", async (req, res) => {
}
}
return res.render("index", {
mtimeJS: Math.floor(fs.statSync("./static/index.js").mtimeMs).toString(36),
mtimeCSS: Math.floor(fs.statSync("./static/style.css").mtimeMs).toString(36),
list: JSON.parse(fs.readFileSync("data/latest.json")).map(({ name, otp }) => ({
name,
otp: "",

View File

@ -17,7 +17,7 @@
<link rel="manifest" href="/manifest.json" />
<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="apple-touch-icon" href="/favicon.png" />
<link rel="stylesheet" href="/style.css" />
<link rel="stylesheet" href="/style.css?<%=mtimeCSS%>" />
<div class="list">
<% list.forEach(function(e){ %>
@ -63,5 +63,5 @@
<input type="submit" />
</form>
</div>
<script src="/index.js" defer></script>
<script src="/index.js?<%=mtimeJS%>" defer></script>
</html>

View File

@ -17,7 +17,7 @@
<link rel="manifest" href="/manifest.json" />
<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="apple-touch-icon" href="/favicon.png" />
<link rel="stylesheet" href="/style.css" />
<link rel="stylesheet" href="/style.css?<%=mtimeCSS%>" />
<div class="counter"></div>
<div class="nav">
@ -25,5 +25,5 @@
<span class="add material-icons">add</span>
</div>
<script src="/login.js" defer></script>
<script src="/login.js<%=mtimeJS%>" defer></script>
</html>

View File

@ -17,7 +17,7 @@
<link rel="manifest" href="/manifest.json" />
<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="apple-touch-icon" href="/favicon.png" />
<link rel="stylesheet" href="/style.css" />
<link rel="stylesheet" href="/style.css?<%=mtimeCSS%>" />
<div class="counter"></div>
<div class="nav">
@ -25,5 +25,5 @@
<span class="add material-icons">add</span>
</div>
<script src="/register.js" defer></script>
<script src="/register.js<%=mtimeJS%>" defer></script>
</html>