invalidate cached pixel

This commit is contained in:
Cory Sanin 2024-01-25 03:45:33 -05:00
parent 278f3ad078
commit 1ee5a42a59
3 changed files with 8 additions and 5 deletions

View File

@ -38,13 +38,16 @@ app.get('/', (req, res) => {
});
});
app.get('/cache-me.webp', (_, res) => {
const sendPixel = (_: express.Request, res: express.Response) => {
res.set('Cache-Control', 'private, max-age=31557600'); // one year
visitCount++;
res.sendFile(Path.join(import.meta.dir, 'assets', 'webp', 'cache-me.webp'));
});
}
app.all('*', (req, res) => {
app.get('/cache-me.webp', sendPixel);
app.get('/cache-me-2.webp', sendPixel);
app.all('*', (req, res) => {
console.log(`404: ${req.url} requested by ${req.ip} "${req.headers['user-agent']}"`);
res.redirect('/');
});

View File

@ -46,7 +46,7 @@ body {
}
#pixel {
background: url('/cache-me.webp');
background: url('/cache-me-2.webp');
position: fixed;
left: -99999999999999px;
top: -20px;

View File

@ -7,7 +7,7 @@
JAKE HURWITZ IS A BITCH
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/assets/css/styles.css?v2">
<link rel="stylesheet" href="/assets/css/styles.css?v3">
</head>
<body>