my application (Restful API, no UI interface at this moment) has the Cache Async in memory functionality at each GET, POST, PUT, DELETE. Does Postman or any API tools has the ability to test the cache function?
3 Answers
No, how would they know the reponse is cached.
- Call API with parameters
- Verify results
- Stop data storage (e.g. database)
- Call API again with same parameters
- Verify same results
How would you do it manually? Does that translate to an automated test?
- Is the second time faster? (if you can measure that)
- Can we make it testable by
- introducing data in the output saying its cached
- adding logs of each request to the datastore and verify it was not accessed by looking at the logs
-
I usually test by stop sql server then query again, if result returned mean cache works. Commented Mar 27, 2020 at 9:44
Since cache is intended to make the interactions faster, you could test if the data was cached on the server side with the help of indirect symptoms.
For example you could clean up the cache and perform some atomic operations with postman. Measure the request execution time (if your requests/operations are synchronous). Then warm up your cache (ask your devs to know what would be the best way to do that) and perform the same steps again. They should take significantly less time.
-
this is complicated as the application did many cache at different places. i would love to test it from any tool like POSTMAN and do not want to touch the codes as defect might invalid if we modify something we are unsure. Commented Mar 27, 2020 at 9:45
Deploy 2 separate services, first with cache enabled, second one without and compare the results.
-
i would not have feasibility to modify the API application. Commented Nov 4, 2019 at 0:54
delete
operations (however still sure it is possible) but "write" cache is a kind of something people use in real life. Basically there is a "fast" layer that the user operates with which is periodically dumped to the persistent memory.