sounisi5011/metalsmith-netlify-published-date

API cache

Opened this issue · 1 comments

In the current code, the response of the Netlify API is not cached in order to get the latest data.
However, fetching data about every deploy has the following problems:

  • Too late. Generally, network requests take time.
  • Netlify API is rate limited. Requests to the API are limited to a maximum of 200 per minute.
  • Network requests can fail. If there is a cache for the preview page, it should be possible to build even without a network connection.

To solve the above problem, we propose to cache the API response.
Data from older deploys will probably not change. Therefore, it should be possible to cache.

I propose JSON Lines as a cache file format.
JSON Lines has the following features:

  • Do not need to pre-parse all data. It is sufficient to read only the required data line by line.
  • The data format is compatible with JSON.