is it possible to do multiple cache timings in single HTTP request in webapi2

388 Views Asked by At

I need to do a multiple caching with different timings in the single webapi call .is it possible in webapi using memory caching.

In Http caching , in single request need to set single expiration, , there are 2 caching, one is for 5 minutes and another for 2 hours in single http request.

In 5 minute caching set in webapi method, but if cache is not available , it will hit other external service url be:https ://www.domain.com/api/sss/ss/ But webapi should call each time ,but external webapi should call only cache expires.which means after 5th second. inside the webapi 2 hours caching , it is memory caching.

 public IHttpActionResult getProduct()
        {

             // cache for 5 minutes:

             if( 5 min cache == null){


                 // call another services url
                 }

        else{
         // taken from  5 MIN cache.
         }


   // cache available take from 5 minutes cache data.

        next : // cache for 2 hours 

             if(2  hours cache != null){
               // get an original data

             }
       //cache available take from 2 hours cache data.




       // add the values in single response as json.
          return  response;

        }
0

There are 0 best solutions below