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 Pages / Clear cache from code
Power Pages
Unanswered

Clear cache from code

(1) ShareShare
ReportReport
Posted on by 104

Hi there,

 

As per the Microsoft Documentation says about caching: 

  • Any record for a table (or a related table) is created, updated, or deleted on the website by any website user. The action will instantaneously clear the cache for all the website users for that specific table.

  • Cache is cleared automatically within 15 minutes even if no changes are made.


Although, If the changes to the table are made directly from an API call, and not through the portal, the cache is not cleared. Therefore, the data in the portal is not refreshed and doesn't show the latest updates.

My question is: is there any way to clear the cache from code, so that the latest updates are shown in the portal, or any good known workaround? 

 

Any idea helps, thank you!

Categories:
I have the same question (0)
  • Ano_niem Profile Picture
    5 on at

    Hi, 

    Regarding your cache not being cleared when you update you data. I had the same issue and found out that using the new enhanced datamodel was the reason why it doesn't clear your cache on a update on your data with the API. When you use the standard datamodel for a Power Page your cache will be cleared when you update your data. So you can fix it by creating a new site with the old/standard datamodel. See here how to disable the enhanced datamodel: https://learn.microsoft.com/en-us/power-pages/admin/enhanced-data-model#disable-the-enhanced-data-model After you did this you can create a new site and this will be created with the standard datamodel. I hope Microsoft will fix this issue soon on the enhanced data model.


    If you don't want to use this solution and just want to clean your cache with code, here is what I think you could do:
    I'm not sure if you can clear you data with code. But when you go <your powerpage url>/_services/about as and user with role admin you will see there a button clear cache. You can look in you devtools what requests are excuted and replicate that. But it could be possible you can only call that endpoint with webrole admin.

    Hope this will help you.

  • Verified answer
    taraubianca25 Profile Picture
    104 on at

    Hi @Ano_niem,

     

    Thanks you for your reply!

    Unfortunately now it's too late to create a new site, because I've already done too much and it would be too much work to just start over. But when I will make a new site I will try your solution with the standard datamodel!

    As a pretty good workaround that I've found up to this point, is the following:

    On the page that I am doing the insert through an API call I've added a Basic Form, linked to the same table that I am creating a new item for. I've hid it, and whenever I make the API call to create a new item, I also Submit automatically the form through a JS function. And this does the trick! 

    Apparently, when the data is changed, it needs to go thorough the Portal in order for the cache to be cleared (in our case we use a Basic Form to save an empty item; so the data goes through the Portal, and therefore the cache is cleared and the data is updated in the Entity List).
    You can read more here: https://www.engineeredcode.com/blog/power-apps-portals-changes-to-caching

  • FelipeBR Profile Picture
    8 on at

    Hi @taraubianca25 ,

     

    Can you show me how you did that "I've hid it, and whenever I make the API call to create a new item, I also Submit automatically the form through a JS function"? I'm having the same problem and i really think this could be the solution for my problem. Thank you in advance

  • taraubianca25 Profile Picture
    104 on at

    Hi @FelipeBR ,

     

    Sorry for replying soo late. I dropped the Power Pages project for a while so I did not access the forum anymore.

    So, the way I remember, is that I put an invisible form on the page. And every time I made an API call to create a new item (add a new record in my table), I submit a form linked to the same data (basically I submit an empty record).
    By submitting a form, the cache is cleared automatically, hence the data is updated.

    This is a pretty good workaround. And the only one I've found.

     

    Hope this still helps 🙂

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 Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard