Skip to content

Commit

Permalink
refactor: add cache control and etag
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha committed Jun 22, 2023
1 parent 047409b commit 4140848
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/lambda-tiler/src/routes/tile.xyz.raster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,12 @@ export const TileXyzRaster = {
});

// If no layers are used and the tile is going to be transparent
// return 204 no content instead
if (res.layers === 0 && layers.length === 1) {
if (background.alpha === 0) return NoContent();
// return 204 no content instead of a empty image
if (res.layers === 0 && background.alpha === 0) {
const response = NoContent();
response.header(HttpHeader.ETag, cacheKey);
response.header(HttpHeader.CacheControl, 'public, max-age=604800, stale-while-revalidate=86400');
return response;
}

req.set('layersUsed', res.layers);
Expand Down

0 comments on commit 4140848

Please sign in to comment.