Simple API Caching for /libraries* requests#2343
Conversation
This didn't seem necessary to me since the update happening on page refresh is the This is a great start for caching the API. Even on my local I can detect the improvement |
|
Sorry about the file naming mistake - slipped from my attention. |
|
Hi, please don't merge this yet. |
|
Yeah I can see that the cached results aren't setting the Content-Type header. Axios on the website must be parsing it as JSON anyway whereas the CapacitorHttp plugin is not. The mobile app is receiving a string instead of a JSON object |
|
OK, fixed now (and also fixed the test). Please take a look again. It now works nicely both on Chrome and and Android. |
|
Working beautifully, thanks! |
|
Can't wait to see this in the next release. Thanks for the effort @mikiher 🙌 |
/libraries* API requests usually fire complex database queries, and those queries exhibit (at least on my setup) inconsistent latencies. In some cases, the same query takes 1-2 orders of magnitude longer to complete (I did not dig deeply into the reasons).
In addition, JSON-stringifying the query results is also expensive.
This adds a simple middleware for caching GET API /libraries* requests.
This seems to improve UI response times visibly (especially when client and server are on the same host), and reduces UI hanging due to query latency inconsistencies.