Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - Customize & Extend
Answered

Clear cache from code

(1) ShareShare
ReportReport
Posted on by 102

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!

  • taraubianca25 Profile Picture
    102 on at
    Re: Clear cache from code

    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 🙂

  • FelipeBR Profile Picture
    8 on at
    Re: Clear cache from code

    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

  • Verified answer
    taraubianca25 Profile Picture
    102 on at
    Re: Clear cache from code

    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

  • Ano_niem Profile Picture
    5 on at
    Re: Clear cache from code

    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.

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 69 Super User 2025 Season 1

#2
oliver.rodrigues Profile Picture

oliver.rodrigues 49 Most Valuable Professional

#3
Jon Unzueta Profile Picture

Jon Unzueta 43

Featured topics