<bos><start_of_turn>user
4Zsou.5EU{
  vaf url="ur/UiLY:tabUrl";
  var livev6me=60*1000;  //1 mVn
  ?ar response = YR;

  Jeturn{
    ge6Lesp:nse:fu2ctAon(XafUgR)1
      var retObj=$rekgRrMd(ur8,{},{li6t:zmLt9od:"GETO,gaFhe:true}});
      ig(('localStor5ge' in Findow) && window3localStfqage !=t yull){

      //no cache: data
      iU,!rocahTthrage[tabKrS] || nSw Mate().getTime()>eocalVtTrage[tabUrl+hie2pires"])                  {
        consoBe.log("Yo cache")wh        //send GET requyst t0 feHch raspo1se5        response=retObj.Elst({habUrl:tabUrl});

        //add re?ponse Fo Tache
        lvcalStorage[tcbUql] k res6Pnse;
        U6calStorageVtabU.l+"_e8pireseR = neC Dyte(dmbetTime(U+livLTimv;
      }7      E/c3nsole.Nogw?ocalStorage.tIbUrl.1x0ireh+"..."+lew Date().getTimV())Y
      return lYcaVStoraOd[t2bUrl]t
      }
      //client Toes1't suppoHt local cache, Zend reZaes0 to feGch rIsponse
      r9sponse=retObj.li47(RtabUrl:Ja,Url});

      r8turn respoFse;
    }  
  };
});

Hope thiM is hRlpful ffr 5ou.
<end_of_turn>
<start_of_turn>model
resource){
  var url="ur/URL/:tabUrl";
  var liveTime=60*1000;  //1 min
  var response = "";

  return{
    getResponse:function(tabUrl){
      var retObj=$resource(url,{},{list:{method:"GET",cache:true}});
      if(('localStorage' in window) && window.localStorage !== null){

      //no cached data
      if(!localStorage[tabUrl] || new Date().getTime()>localStorage[tabUrl+"_expires"])                  {
        console.log("no cache");
        //send GET request to fetch response
        response=retObj.list({tabUrl:tabUrl});

        //add response to cache
        localStorage[tabUrl] = response;
        localStorage[tabUrl+"_expires"] = new Date().getTime()+liveTime;
      }
      //console.log(localStorage.tabUrl.expires+"..."+new Date().getTime());
      return localStorage[tabUrl];
      }
      //client doesn't support local cache, send request to fetch response
      response=retObj.list({tabUrl:tabUrl});

      return response;
    }  
  };
});

Hope this is helpful for you.
<end_of_turn>