Reducing server calls not only improves the performance and responsiveness of your Power Pages site but also enhances scalability and reduces Dataverse API consumption. Here’s how you can avoid unnecessary server calls:
1. Use Caching Strategically
- Liquid Caching: Use
{% cache %}
tags in Liquid templates for content that doesn’t change often.{% cache 'recent-news', 300 %} {% include 'RecentNewsSnippet' %} {% endcache %}
- Output Caching: Cache entire sections (e.g., headers, footers, navigation) where content is static.
2. Filter Data at the Source
- Optimize FetchXML Queries:
- Avoid fetching all records (
count="5000"
) when you only need a few. - Use
top
andfilter
conditions to narrow results.
- Avoid fetching all records (
- Use System Views and Custom Views: Predefine filters in Dataverse views and use them in Entity Lists or Liquid to reduce data load.
🔹 3. Limit Use of Liquid Loops Over Queries
- Avoid nested loops on entity queries inside Web Templates or Page Templates. They trigger Dataverse calls every iteration.
{% assign contacts = entities.contact | where: 'statuscode', 1 %} {% for contact in contacts %} {{ contact.fullname }} {% endfor %}
Better: Fetch only required fields and records using FetchXML once, then iterate.
4. Use JavaScript Judiciously
- Avoid Redundant Ajax Calls: Cache results in memory if the same data is being used repeatedly.
- Use
sessionStorage
orlocalStorage
: Store frequently-used user data like profile or preferences to avoid fetching on each page.
5. Use Conditional Visibility
- Show/hide controls or fields client-side when possible instead of rendering different components from the server.
- In forms, use Business Rules or JavaScript to control field visibility without triggering re-renders.
6. Paginate Data
- In Entity Lists or custom displays, always use pagination instead of loading all data at once.
- Example: Limit results to 10–20 items per page.
7. Avoid Redundant FetchXML Calls
- If the same data is being fetched multiple times on a page (like in multiple Liquid includes), store it in a variable:
{% assign user = user %} {{ user.fullname }}
8. Leverage Server-Side Processing
- Offload complex logic to Power Automate or plugins where applicable, then return only final results to the page.
9. Audit with Browser Dev Tools
- Use Network tab in Chrome DevTools to detect repetitive calls.
- Track how many times a resource (like a Web API or Liquid loop) is being called per user action.
10. Avoid Misuse of Web Files
- Don’t load large JavaScript or JSON files dynamically unless required.
- Combine and minify assets to reduce requests.