const express = require('express'); const path = require('path'); const PUBLIC_ROOT = path.join(__dirname, '..', 'public'); module.exports = express.static(PUBLIC_ROOT, { etag: true, lastModified: true, cacheControl: true, setHeaders(res, filePath) { const normalizedPath = filePath .replaceAll('\\', '/') .toLowerCase(); const isThumbnail = normalizedPath.includes('/photos/') && normalizedPath.includes('/thumbs/') && /\.(jpg|jpeg|png|webp|gif)$/i.test(normalizedPath); if (isThumbnail) { res.setHeader( 'Cache-Control', 'public, max-age=86400' ); } } });