mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
* Disable default static caching for app's index page * Update index.html related environment variables in `.env.example` * Fix linting * Update index.spec.js --------- Co-authored-by: Danny Avila <danacordially@gmail.com>
20 lines
661 B
JavaScript
20 lines
661 B
JavaScript
const expressStaticGzip = require('express-static-gzip');
|
|
|
|
const oneDayInSeconds = 24 * 60 * 60;
|
|
|
|
const sMaxAge = process.env.STATIC_CACHE_S_MAX_AGE || oneDayInSeconds;
|
|
const maxAge = process.env.STATIC_CACHE_MAX_AGE || oneDayInSeconds * 2;
|
|
|
|
const staticCache = (staticPath) =>
|
|
expressStaticGzip(staticPath, {
|
|
enableBrotli: false, // disable Brotli, only using gzip
|
|
orderPreference: ['gz'],
|
|
setHeaders: (res, _path) => {
|
|
if (process.env.NODE_ENV?.toLowerCase() === 'production') {
|
|
res.setHeader('Cache-Control', `public, max-age=${maxAge}, s-maxage=${sMaxAge}`);
|
|
}
|
|
},
|
|
index: false,
|
|
});
|
|
|
|
module.exports = staticCache;
|