Clear Cache Item
Audience:
Low-code Engineers,System/Security AdministratorsSkill Prerequisites:
Actions,System Administration
Removes data from the server cache, so it's loaded fresh the next time it's needed. You can clear the items whose key starts with a given text, the page (tabs) cache or portal cache of one or more portals, or the whole cache.
Use it after changing data directly, for example with SQL, when the site keeps showing the old values.
Typical Use Cases
- Clear cached items after updating a table with Run SQL Query, so the site shows the new data
- Refresh the pages (tabs) cache after pages or their settings were changed outside the usual screens
- Refresh the portal cache of several portals after changing portal settings
- Clear the whole cache as part of a maintenance job
Don't use it to
- Refresh a user's cached data. Use Clear User Cache instead.
- Clear the whole cache on every submission. It slows down the whole site while everything is loaded again.
Related Actions
| Action Name | Description |
|---|---|
| Clear User Cache | Clears the cached data of a user, or of the current user. |
| Run SQL Query | Changes data directly, which may leave old values in the cache. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| Clear All Cache | Clears the entire DNN cache, the same as clearing the cache in the DNN Persona Bar. When it's on, the other options are hidden and ignored. | No | false | No |
| Clear Tabs Cache | Clears the pages (tabs) cache of the current portal, or of each portal in Portal IDs. | No | false | No |
| Clears Portal Cache | Clears the portal cache of the current portal, or of each portal in Portal IDs, including the cached items that depend on it. | No | false | No |
| Portal IDs | The portals to clear the tabs or portal cache for, for example 0,1,2. Separate IDs with commas, semicolons or new lines. If it's empty, the current portal is used. Only shown when Clear Tabs Cache or Clears Portal Cache is on. | Yes | empty string | No |
| Cache Key | Removes every cache item whose key starts with this text, for example Tab_Tabs clears the tabs cache on all portals. A full key removes just that item. | Yes | empty string | No |
How it works
- If Clear All Cache is on, the whole cache is cleared and nothing else is done. DNN writes an entry to the Event Viewer.
- Otherwise, each option that's set runs in this order: Clear Tabs Cache, Clears Portal Cache, then Cache Key. You can combine them.
- If nothing is set, the action does nothing.
- If Portal IDs contains something that isn't a whole number, the action fails with
Error parsing Portal IDs.
Viewing The Server Cache
The action's help used to include a link to a list of the items in your server cache. That list was removed for security reasons, because it could show cached data to users without permission.
If you need to see the cache keys, you can build a page that only site administrators can open:
-
Go to Plant an App Configuration and open Tokens in the left menu.
-
Select an existing NameSpace or create a new one.
-
Hover over the NameSpace row and click the Create Token (plus icon) button.
-
Enter a Token Name and Description.
-
Click Definition and select Razor Script.
-
In the Code Language dropdown, select C#.
-
In the Script box, paste this script:
@{foreach (System.Collections.DictionaryEntry cacheItem in System.Web.HttpRuntime.Cache) {var cacheStr = string.Format("<b>{0}</b>: {1}<br/>", cacheItem.Key, cacheItem.Value);@:@cacheStr}} -
Click Save & Test. The cache list appears in the results box.
-
Use the token on a page in an HTML module. In the module settings, on the HTML Module Settings tab, turn on Replace Tokens.
For the security of your site, only users with site administration rights should be able to open the page that lists the server cache. Set the page permissions accordingly.
Considerations
- Cache keys are matched by their start. A short key such as
Tabcan remove many items. Use the longest key that still matches what you need. - Clearing the cache affects everyone. Pages are slower until the data is cached again. Clear only what you need, and avoid clearing the whole cache during busy hours.
- Add a condition if you only want to clear the cache in some cases. See Common Parameters.
Examples
To understand how to use the below examples, please see Running Examples.
1. Clear the pages cache on all portals
This action removes every cache item whose key starts with Tab_Tabs, which clears the pages cache on all portals.
{
"Title": "Clear Cache Item",
"ActionType": "ClearCacheItem",
"Description": "Clear the pages cache on all portals",
"Parameters": {
"ClearAllCache": false,
"CacheKey": "Tab_Tabs"
}
}
2. Clear the tabs and portal cache for two portals
This action clears the pages cache and the portal cache for portals 0 and 2.
{
"Title": "Clear Cache Item",
"ActionType": "ClearCacheItem",
"Description": "Refresh portals 0 and 2",
"Parameters": {
"ClearAllCache": false,
"ClearTabsCache": true,
"ClearPortalsCache": true,
"PortalIds": "0,2"
}
}
3. Clear the whole cache from a maintenance job
This action clears the entire cache, but only when the ClearAll token is Yes.
{
"Title": "Clear Cache Item",
"ActionType": "ClearCacheItem",
"Description": "Clear the whole server cache",
"Condition": "[ClearAll] == \"Yes\"",
"Parameters": {
"ClearAllCache": true
}
}
Revised 09/26/2026