web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How Caching can be don...
Power Apps
Unanswered

How Caching can be done in Canvas Apps PoweApps?

(0) ShareShare
ReportReport
Posted on by 4

I am stuck with a problem to implement Caching in Canvas Apps PowerApps, but I am unable to find an apt solution for this and not even confirm if it is possible or not?

I tried using Collections but still I'm unable to achieve caching using this approach.  Please help!! @RezaDorrani @RandyHayes @WarrenBelz 

Categories:
I have the same question (0)
  • timl Profile Picture
    36,393 Super User 2025 Season 2 on at

    @mishralock10 

    Collections are the way in which you would cache data on a per user/per session basis.

    https://learn.microsoft.com/en-us/power-apps/maker/canvas-apps/working-with-data-sources#collections

     

    What is it that you are unable to achieve? What have you tried?

  • Andreas Hassing Profile Picture
    Microsoft Employee on at

    It sounds like you're looking for the functionality of SaveData and LoadData.

    SaveData, LoadData, and ClearData functions in Power Apps - Power Platform | Microsoft Learn

  • mishralock10 Profile Picture
    4 on at

    Thanks for responding @timl I basically tried to use collection and applied it on "OnStart" property of the App (Sample app). But while doing so, I was not getting a proper Idea how to take things further.

  • mishralock10 Profile Picture
    4 on at

    Thanks @AndreasHMSFT  , appreciate your response, I'll look into it and try to implement it, hope this works. 

  • mwoollen Profile Picture
    26 on at

    I have recently thought about caching in Powerapps using collections.  Cached data can help with performance.  I've been investigating the use of SharePoint REST APIs in place of Connectors to SharePoint... 1. you can avoid challenges with delegation, 2. you can leverage pagination, 3. you can cache SP JSON responses.  Caching, to me, implies that you want to check the cache for a valid entry that both exists in the cache and has not yet expired.  3 phase logic follows:

    1. If the entry is valid (exists and has not expired), then just simply return the cached data from the cache/collection.

    2. If the entry exists in the collection, but has expired (e.g. the data hasn't been refreshed in x number of seconds, then get a fresh copy of the data and update (patch) the invalid entry.

    3. If there is no entry in the cache, then get a fresh copy of the data and save (patch) in the cache (collection)

     

    Coalesce helps to facilitate this.  Coalesce will essentially try an option and if that option is invalid, it will try the next option.

     

    I have created a "Power Automate" flow called "HT - Generic SP Call" that makes a generic "GET" call to SharePoint and returns the resulting JSON (even if the JSON results contain a list... I can store this as a Single entry in my cache and set a timestamp.  This flow does not require any premium connectors or special magic.  

    In the first step, define two inputs: in_baseurl and in_restcall.

    In the second step, send in_baseurl to Site Address and in_restcall to URI.  Also add Header "Accept" = 

    "application/json;odata=nometadata".  I also rename this step = "HTTP _Request"
    In the third step, return "data" with expression "string(body('HTTP_Request'))"

     

    Now, you can add this flow to Powerapps using the "Power Automate" configuration button.

     

    Now, back to cache (collection) in Powerapps.  A collection called coll_httprequests with columns "httprequest", "httpresponse", and "timestamp" will be created by the component and available to your Powerapps.  My cached item in this case will expire after 145 seconds.  

     

    Create an invisible component, add a property named "get" of type "Action" that returns Text.  Add 3 input parameters: in_baseurl (type text), in_request_uri (type text), and in_expiry (type number).  Place the following in the result.

     

     

     

    If(LookUp(Sort(coll_httprequests,timestamp,SortOrder.Ascending),httprequest=in_request_uri).timestamp > (Now() - in_expiry/24/60/60), LookUp(Sort(coll_httprequests,timestamp,SortOrder.Ascending),httprequest=in_request_uri), Patch(coll_httprequests, Coalesce( LookUp(Sort(coll_httprequests,timestamp,SortOrder.Ascending),httprequest=in_request_uri), Defaults(coll_httprequests)), {httprequest:in_request_uri,httpresponse:'HT-GenericSPCall'.Run(in_baseurl,in_request_uri).data,timestamp:Now()} )).httpresponse

     

     

     

    Now, add this component to your Powerapps.  And now you can call Component_1.get("https://_____.sharepoint.com/sites/____", "_api/web/lists",30).  And then parse the results into a Table.  This is a little tricky... you need to know the structure of the response.  See https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-lists-and-list-items-with-rest.

     

     

     

    Set(var_getit7, SPConnect.get(var_baseurl,"_api/web/lists",60));
    
    ClearCollect(coll_splists,
     DropColumns(AddColumns(
     Table(ParseJSON(var_getit7).value),
     "Title", Text(Value.Title),
     "Id", Text(Value.Id),
     "Description", Text(Value.Description),
     "DecodeURL", Text(Value.ParentWebPath.DecodedUrl),
     "ImageURL", Text(Value.ImageUrl)
     ),"Value"));

     

     

    I provided some "write up" on how to do the Power Flow HTTP call to SharePoint in a "non-premium" way.  https://sharepoint.stackexchange.com/questions/282308/how-to-send-json-data-to-power-apps-from-power-automate-ms-flow

     

    Cheers!

     

     

     

     

     

     

     

     

     

     

     

     

    mwoollen_1-1707075665074.png

    mwoollen_0-1707075303859.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard