Caching data
In this section, we are going to cache requests for getting a question. At the moment, the database is queried for each request to get a question. If we cache a question and can get subsequent requests for the question from the cache, this should be faster and reduce the load on the database. We will prove this with load tests.
Load testing the current implementation
Before we implement caching, we are going to load test the current implementation of getting a single question using the following steps:
- Let's start our REST API by pressing F5 in Visual Studio.
- Now, we can load test the current implementation using WebSurge. Let's set the request URL path toÂ
/api/questions/1
 and change the duration toÂ30
 seconds withÂ5
 threads. - Start the test. When the test has finished, we'll get our results: