adoptium / api.adoptium.net

Adoptium API 🚀
https://api.adoptium.net
Apache License 2.0
32 stars 26 forks source link

Implement http cache validation control in the API #1017

Open tellison opened 2 months ago

tellison commented 2 months ago

To potentially reduce the response time for end users, and reduce the workload on the API server, the Adoptium API should implement some simple cache validation support.

Most of the responses from the Adoptium API vary infrequently, and we already know when the response's data are updated in the local database cache since they are updated via our own updater. By returning HTTP cache control headers and honoring corresponding HTTP request headers, the payload may be omitted in many of the responses.

For example, knowing when the API database is updated the server can return an entity tag validator which can be stored by clients and used to check their cache validity. Best practice is also to return a Last-Modified timestamp and check the If-Modified-Since header in requests.

This would be a new feature, and could be a good enhancement for a project to add this capability progressively to the API.