Skip to content

Commit

Permalink
Improved the caching of the API requests (#19)
Browse files Browse the repository at this point in the history
* Limit zoom to 11 (#17)

* API only adds caching headers for calls with a zoom level smaller than 5

* Removed the caching for API requests to 'change endpoints'

Co-authored-by: Alvaro <[email protected]>
  • Loading branch information
santostiago and Bluesmile82 authored Dec 4, 2020
1 parent 6552afc commit b10b308
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 8 deletions.
1 change: 0 additions & 1 deletion api/tiles/soc-experimental-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ module.exports = ({ params: { type, depth, year1, year2, x, y, z } }, res) => {
});
await serverPromise.then(serverResponse => {
res.set('Content-Type', 'image/png');
res.set('Cache-Control', 'public,max-age=604800');
return res.send(Buffer.from(serverResponse.data));
});
});
Expand Down
4 changes: 3 additions & 1 deletion api/tiles/soc-experimental-timeseries.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ module.exports = ({ params: { type, depth, year, x, y, z } }, res) => {
});
await serverPromise.then(serverResponse => {
res.set('Content-Type', 'image/png');
res.set('Cache-Control', 'public,max-age=604800');
if (z < 5) {
res.set('Cache-Control', 'public,max-age=604800');
}
return res.send(Buffer.from(serverResponse.data));
});
});
Expand Down
1 change: 0 additions & 1 deletion api/tiles/soc-stock-future-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ module.exports = ({ params: { scenario, year, x, y, z } }, res) => {
});
await serverPromise.then(serverResponse => {
res.set('Content-Type', 'image/png');
res.set('Cache-Control', 'public,max-age=604800');
return res.send(Buffer.from(serverResponse.data));
});
});
Expand Down
4 changes: 3 additions & 1 deletion api/tiles/soc-stock-future-period.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ module.exports = ({ params: { scenario, year, x, y, z } }, res) => {
});
await serverPromise.then(serverResponse => {
res.set('Content-Type', 'image/png');
res.set('Cache-Control', 'public,max-age=604800');
if (z < 5) {
res.set('Cache-Control', 'public,max-age=604800');
}
return res.send(Buffer.from(serverResponse.data));
});
});
Expand Down
1 change: 0 additions & 1 deletion api/tiles/soc-stock-historic-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ module.exports = ({ params: { depth, x, y, z } }, res) => {
});
await serverPromise.then(serverResponse => {
res.set('Content-Type', 'image/png');
res.set('Cache-Control', 'public,max-age=604800');
return res.send(Buffer.from(serverResponse.data));
});
});
Expand Down
4 changes: 3 additions & 1 deletion api/tiles/soc-stock-historic-period.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ module.exports = ({ params: { depth, period, x, y, z } }, res) => {
});
await serverPromise.then(serverResponse => {
res.set('Content-Type', 'image/png');
res.set('Cache-Control', 'public,max-age=604800');
if (z < 5) {
res.set('Cache-Control', 'public,max-age=604800');
}
return res.send(Buffer.from(serverResponse.data));
});
});
Expand Down
1 change: 0 additions & 1 deletion api/tiles/soc-stock-recent-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ module.exports = ({ params: { year1, year2, x, y, z } }, res) => {
});
await serverPromise.then(serverResponse => {
res.set('Content-Type', 'image/png');
res.set('Cache-Control', 'public,max-age=604800');
return res.send(Buffer.from(serverResponse.data));
});
});
Expand Down
4 changes: 3 additions & 1 deletion api/tiles/soc-stock-recent-timeseries.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ module.exports = ({ params: { year, x, y, z } }, res) => {
});
await serverPromise.then(serverResponse => {
res.set('Content-Type', 'image/png');
res.set('Cache-Control', 'public,max-age=604800');
if (z < 5) {
res.set('Cache-Control', 'public,max-age=604800');
}
return res.send(Buffer.from(serverResponse.data));
});
});
Expand Down
1 change: 1 addition & 0 deletions components/map/map/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const Comp = (
height="100%"
mapStyle={mapStyle}
asyncRender
maxZoom={11}
{...internalViewport}
{...(isStatic
? {}
Expand Down

0 comments on commit b10b308

Please sign in to comment.