Skip to content

Commit

Permalink
Vary on accept when auto converting assets (directus#18228)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbicou committed Apr 18, 2023
1 parent 882685e commit ae0d960
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/src/controllers/assets.ts
Expand Up @@ -141,6 +141,8 @@ router.get(
schema: req.schema,
});

const vary = ['Origin', 'Cache-Control'];

const transformation: TransformationParams = res.locals['transformation'].key
? (res.locals['shortcuts'] as TransformationParams[]).find(
(transformation) => transformation['key'] === res.locals['transformation'].key
Expand All @@ -157,6 +159,7 @@ router.get(
}

transformation.format = format;
vary.push('Accept');
}

let range: Range | undefined = undefined;
Expand Down Expand Up @@ -186,6 +189,7 @@ router.get(
res.setHeader('Content-Type', file.type);
res.setHeader('Accept-Ranges', 'bytes');
res.setHeader('Cache-Control', getCacheControlHeader(req, getMilliseconds(env['ASSETS_CACHE_TTL']), false, true));
res.setHeader('Vary', vary.join(', '));

const unixTime = Date.parse(file.modified_on);

Expand Down

0 comments on commit ae0d960

Please sign in to comment.