Developer forum

Forum » Integration » Issues with custom URL Provider

Issues with custom URL Provider

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,
We are struggling with some challenges related to a custom URL provider, or rather with the invalidation of the URL cache.

In order to have custom friendly urls we have created a class inherited from UrlDataProvider overriding function GetUrlDataNodes

(public override IEnumerable<UrlDataNode> GetUrlDataNodes(UrlDataNode parent, UrlDataContext dataContext)).

There are cases when these friendly urls need to be regenerated (the name of some custom category changes); for this, we call UrlHelper.SetResetNeeded();

Is it enough?

(It seems like function UrlHelper.CheckResetNeeded() should use properties set by UrlHelper.SetResetNeeded() but I think that UrlHelper.CheckResetNeeded() is not called)

When should we expect UrlHelper.CheckResetNeeded() to be called?
Thank you,
Adrian


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Adrian,

SetResetNeeded() is enough — but with one note:

The flow:

  1. You call UrlHelper.SetResetNeeded() → sets a static ResetNeeded = true flag + captures a timestamp.
  2. CheckResetNeeded() is called by UrlIndexResetHandlerMiddleware at the start of every incoming HTTP request.
  3. It waits for a 2-second debounce — only triggers the actual ResetPageIndex() if at least 2 seconds have elapsed since SetResetNeeded() was called.
  4. ResetPageIndex() clears and rebuilds the URL index, which will call your GetUrlDataNodes override again.

So calling SetResetNeeded() is the correct approach — the rebuild happens on the next HTTP request that arrives 2+ seconds later.

Your suspicion about CheckResetNeeded() not being called

It is being called — via UrlIndexResetHandlerMiddleware. The 2-second grace period is intentional (debouncing rapid successive changes). If your category rename triggers SetResetNeeded() and a frontend request comes in 2+ seconds later, the rebuild will fire.

BR, Dmitrij

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Thank you very much, Dmitrij!

Adrian

 

You must be logged in to post in the forum