Set up cache invalidation to refresh changes on the website (Dynamics CRM 2015)

 

Applies To: Dynamics CRM 2015

Websites developed using Developer Extensions for Microsoft Dynamics CRM 2015 make heavy use of caching. As a result, changes made to Microsoft Dynamics CRM entities in the web application or in Microsoft Dynamics CRM Online may not immediately show up on the website. To resolve this, you can set up cache invalidation to happen automatically with the use of the web notification plug-ins and web notification URLs.

If the web notification plug-ins are installed, ensure that they are enabled for the solution.

Enable Web notification plug-ins

The web notification plug-in assembly is contained within portal managed solutions and is installed by importing one of those solutions. The “base” solution is included with Microsoft Dynamics CRM SDK. Solutions with additional customizations are included with the Customer Portal and Partner Portal. For links to these solutions, see Portal developer guide for Microsoft Dynamics CRM 2015.

Next, create a new web notification URL (from the Settings menu) that goes to the cache invalidation handler of your website. The URL to your cache invalidation will be http(s)://your-website-domain/Cache.axd.

Web notification URL

Now, when entities are created, updated, or deleted, the cache invalidation handler for your website will be notified and will invalidate the necessary cache depending on what has changed.

Cache can also be invalidated manually by recycling the application pool, rebuilding the website in Microsoft Visual Studio, saving the web.config file, or by adding a browser toolbar button that will hit the cache invalidation handler. This will refresh the website with the Microsoft Dynamics CRM changes.

The toolbar script is a link or shortcut that is added into your browser favorites with the value for its URL as shown here.

In Internet Explorer, use this script:

javascript:var sURL=document.location.protocol + '//' +document.location.host;var oHttp=new ActiveXObject("Msxml2.XMLHTTP.6.0"); oHttp.Open('GET',sURL+'/Cache.axd?Message=InvalidateAll&d=' + (new Date()).valueOf(),false);oHttp.Send();window.location.reload(true);

In Firefox, use this script:

javascript:var%20url%20=%20document.location.protocol%20+%20'//'%20+%20document.location.host%20+%20'/Cache.axd?Message=InvalidateAll&d='%20+%20(new%20Date()).valueOf();%20var%20req%20=%20new%20XMLHttpRequest();%20req.open('GET',%20url,%20false);%20req.send(null);window.location.reload(true);

To use the script, just open the website you want to refresh and then click your favorite that you set previously. The cache for that website will be invalidated and you should see the changes you made.

See Also

Manage portal content (Dynamics CRM 2015)
Portal developer guide for Microsoft Dynamics CRM 2015
Manually create a new website using developer extensions for Dynamics CRM 2015

© 2016 Microsoft. All rights reserved. Copyright