Hi Sravya,
In answer to your question, no API key is not mandatory for Caching.
I tested an API Proxy of my own using the code you provided and it hit the cache.
So to troubleshoot:
1) Are you attempting to cache a huge amount of data in a single request? E.g. > 4MB?
2) Do you have the same cache code in both your Response Cache policies (Preflow incoming/outgoing)?
3) Do you have any other policies / options on the API proxy? If so, what is the arrangement of policies?