mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 10:20:15 +01:00
🔄 feat: Add Configurable Cache Headers for Index.html (#4565)
* refactor: move o1 model check, after vision request check * feat(server): add configurable cache headers for index.html • Add environment variables to control index.html cache headers • Default to no-cache configuration for consistent app updates • Document cache control options in .env.example
This commit is contained in:
parent
a1647d76e0
commit
b939e24f67
4 changed files with 26 additions and 8 deletions
|
|
@ -112,10 +112,16 @@ const startServer = async () => {
|
|||
app.use('/api/tags', routes.tags);
|
||||
|
||||
app.use((req, res) => {
|
||||
// Replace lang attribute in index.html with lang from cookies or accept-language header
|
||||
res.set({
|
||||
'Cache-Control': process.env.INDEX_CACHE_CONTROL || 'no-cache, no-store, must-revalidate',
|
||||
Pragma: process.env.INDEX_PRAGMA || 'no-cache',
|
||||
Expires: process.env.INDEX_EXPIRES || '0',
|
||||
});
|
||||
|
||||
const lang = req.cookies.lang || req.headers['accept-language']?.split(',')[0] || 'en-US';
|
||||
const saneLang = lang.replace(/"/g, '"'); // sanitize untrusted user input
|
||||
const saneLang = lang.replace(/"/g, '"');
|
||||
const updatedIndexHtml = indexHTML.replace(/lang="en-US"/g, `lang="${saneLang}"`);
|
||||
res.type('html');
|
||||
res.send(updatedIndexHtml);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue