How to cache API requests in Express
Thread ๐งต๐
Thread ๐งต๐
Caching is a technique that stores frequently accessed data in a temporary storage area to retrieve it when needed quickly.
It speeds up access to the data and reduces the strain on the system that would otherwise be caused by constantly retrieving the same data from its original location.
Let's show how we can implement caching in the NodeJs Express API app.
Let's show how we can implement caching in the NodeJs Express API app.
We will use a package called "apicache" for this.
First, install the package by running the following command in your terminal.
`npm i apicache`
First, install the package by running the following command in your terminal.
`npm i apicache`
We pass the actual number of minutes we want to cache the results.
In our case, it's 2 minutes.
Duration is in the following format "[length][unit]", as in "10 minutes" or "1 day"
In our case, it's 2 minutes.
Duration is in the following format "[length][unit]", as in "10 minutes" or "1 day"
Hope you enjoyed this thread.
If you found this thread useful, follow @Rapid_API ๐๐
If you found this thread useful, follow @Rapid_API ๐๐
Loading suggestions...