Add way to set Cache-Control header for static assets

Fixes #3332
This commit is contained in:
rijkvanzanten
2020-12-16 13:53:09 -05:00
parent 999036ae94
commit ab0ade5375
3 changed files with 86 additions and 82 deletions

View File

@@ -9,6 +9,7 @@ import { Transformation } from '../types/assets';
import storage from '../storage';
import { PayloadService, AssetsService } from '../services';
import useCollection from '../middleware/use-collection';
import env from '../env';
const router = Router();
@@ -111,6 +112,7 @@ router.get(
res.removeHeader('Content-Disposition');
}
res.setHeader('Cache-Control', env.ASSETS_CACHE_CONTROL);
stream.pipe(res);
})
);

View File

@@ -44,6 +44,8 @@ const defaults: Record<string, any> = {
EMAIL_SENDMAIL_PATH: '/usr/sbin/sendmail',
TELEMETRY: true,
ASSETS_CACHE_CONTROL: 'public, max-age=604800',
};
let env: Record<string, any> = {