On February 12th, SDL released DXA 2.0, the shiny new version of the Digital Experience Accelerator. Part of this new version is a new REST service called the model service, which is able to return content quicker, and in a leaner format. Not only that, the model service is also able to resolve links in the content on the fly. This is an important improvement, because link resolving is one of the most expensive operations in DXA as well as DD4T.
A full migration of your application from DD4T to DXA is far from trivial, at least not with the DXA 2.0 release that is currently out. But there is good news: it is very easy to start using the DXA model service in your DD4T .NET application (it is also possible with a Java DD4T application, but we’ll discuss that some other time). Your application is likely to become faster because of it.
There is one important condition: you have to use SDL Web 8.1 or higher, and DD4T 2.0 or higher, in order to upgrade to the model service.
All you have to do if you want to switch to the model service – and profit from a better performance – is to install the model service, and start using the new DxaModelService DD4T Provider.
Here are the steps:
- Download the Digital Experience Accelerator version 2.0: https://appstore.sdl.com/web-content-management/app/sdl-digital-experience-accelerator-net/608
- Install the model service as described in the documentation. You do NOT need to install the CMS or .NET Web App parts of DXA!
- Open your web application in Visual Studio
- Using Manage Nuget Packages for Solution, remove the DD4T provider you’re currently using (e.g. DD4T.Providers.SDLWeb8.5.CIL)
- Add a reference to DD4T.Providers.DxaModelService
- Rebuild the application and run.
That’s all there’s to it . You don’t need to change any configuration. The Discovery Service (which is configured with the discovery-service-uri appSetting) will return the URL of the model service.
Troubleshooting
If it’s not working directly, you should check first if the model service is working. If your CIS services (microservices) are not authenticated, you can access the model service directly from your browser as follows:
http://my-hostname:8888/PageModel/tcm/2/url/to/page
Please replace the hostname and the port with the correct settings for your environment. The number 2 is the publication ID, you probably need to change that as well. And the rest or the URL is simply the URL of the page. The file extension of your page URL is optional.
If your microservices are authenticated, please consult this blog.
Is republishing necessary?
The model service can consume two types of JSON data:
- The new DXA 2 data format
- The DD4T 2 data format
If you’re already using DD4T 2 templates right now, there is no reason to change this right away. You can keep using your current template set, and you don’t need to republish anything.
However, the DXA 2 data format is more compact and will probably make publishing a bit faster. If republishing all your sites does not scare you, you might consider to replace the DD4T template building blocks with the new DXA 2 TBBs and republish.
Link resolving
The model service can resolve links for you. But how does it do this exactly? What configuration options are there? Does it work for rich text fields? Is it still possible to override the default linking logic?
I will explain this in another blog. Coming soon!