Skip to content

Commit

Permalink
perf(CustomServer): Keep favicon in memory (#10628)
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree authored Aug 30, 2024
1 parent 3da50ba commit 730fda2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/routes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path');
const fs = require('fs');

const express = require('express');
const proxy = require('express-http-proxy');
Expand All @@ -22,8 +23,12 @@ module.exports = expressApp => {

app.get('/static/*', maxAge(86400));

// Load the favicon file into memory
const faviconPath = path.join(__dirname, '../public/static/images/favicon.ico.png');
const favicon = fs.readFileSync(faviconPath);
app.get('/favicon.*', maxAge(300000), (req, res) => {
return res.sendFile(path.join(__dirname, '../public/static/images/favicon.ico.png'));
res.type('image/png');
return res.send(favicon);
});

/* Helper to enable downloading files that are on S3 since Chrome and Firefox does
Expand Down

0 comments on commit 730fda2

Please sign in to comment.