Skip to content

Commit 53e509e

Browse files
alison-mkCopilot
andauthored
[Excel] (Custom functions) Add new cache clear guidance (#5152)
* [Excel] (Custom functions) Add new cache clear guidance * Fix typo * Update docs/excel/custom-functions-troubleshooting.md Co-authored-by: Copilot <[email protected]> * Incorporate code review feedback, add TIP from PM * Add notes for how to disable and how to call in office.onready * Adjust comment spacing and date * Add shared runtime requirement --------- Co-authored-by: Copilot <[email protected]>
1 parent 2be1267 commit 53e509e

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

docs/excel/custom-functions-troubleshooting.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
ms.date: 06/09/2022
2+
ms.date: 05/20/2025
33
description: Troubleshoot common problems with Excel custom functions.
44
title: Troubleshoot custom functions
55
ms.topic: troubleshooting
@@ -38,6 +38,47 @@ Generally, these errors correspond to the errors you might already be familiar w
3838

3939
Information about custom functions is cached by Office. Sometimes while developing and repeatedly reloading an add-in with custom functions your changes may not appear. You can fix this by clearing the Office cache. For more information, see [Clear the Office cache](../testing/clear-cache.md).
4040

41+
### Clear the custom functions cache when your add-in runs
42+
43+
There may be times when you need to clear the custom functions cache for an add-in deployed to your end users, so that add-in updates and custom functions setting changes are incorporated at the same time. Without triggering a custom functions cache clear, changes to the **functions.json** and **functions.js** files may take up to 24 hours to reach your end users, while changes to **taskpane.html** reach end users more quickly.
44+
45+
> [!NOTE]
46+
> Once this setting is turned on for a document, it takes effect the next time the document is opened with the add-in. It doesn't apply immediately after the function is called.
47+
48+
To ensure that the custom functions cache is cleared by your add-in, add the following code to your **functions.js** file, and then call the `setForceRefreshOn` method in your `Office.onReady` call or other add-in initialization logic.
49+
50+
> [!IMPORTANT]
51+
> This process for clearing the custom functions cache is only supported for custom functions add-ins that use a [shared runtime](../testing/runtimes.md#shared-runtime).
52+
53+
```javascript
54+
// To enable custom functions cache clearing, add this method to your functions.js
55+
// file, and then call the `setForceRefreshOn` method in your `Office.onReady` call.
56+
function setForceRefreshOn() {
57+
Office.context.document.settings.set(
58+
'Office.ForceRefreshCustomFunctionsCache',
59+
true
60+
);
61+
Office.context.document.settings.saveAsync();
62+
}
63+
```
64+
65+
> [!TIP]
66+
> Frequently refreshing the custom functions cache can impact performance, so clearing the custom functions cache with `setForceRefreshOn` should only be used during add-in development or to resolve bugs. Once a custom functions add-in is stabilized, stop forcing cache refreshes.
67+
68+
To disable the custom functions cache clear in your add-in, set `Office.ForceRefreshCustomFunctionsCache` to `false` and call the method in your `Office.onReady` call. The following code sample shows an example with a `setForceRefreshOff` method.
69+
70+
```javascript
71+
// To disable custom functions cache clearing, add this method to your functions.js
72+
// file, and then call the `setForceRefreshOff` method in your `Office.onReady` call.
73+
function setForceRefreshOff() {
74+
Office.context.document.settings.set(
75+
'Office.ForceRefreshCustomFunctionsCache',
76+
false
77+
);
78+
Office.context.document.settings.saveAsync();
79+
}
80+
```
81+
4182
## Common problems and solutions
4283

4384
### Can't open add-in from localhost: Use a local loopback exemption

0 commit comments

Comments
 (0)