Causing Delay for custom APIs
Hello, love the module, I just have a little issue...
The site I administer is over 3 years old and is constantly updated, as a consequence the Auto Generated URLs have accumulated over time into the many thousands, 7300 in fact. This became an issue because calls to extremely simple APIs were taking 2-3 seconds to respond.
It is definitely the Redirect Module causing the delay because I can see the time taken in Sitecores Admin Pipeline profiler. Also because the test web service is minimal code returning 'hello world'.
I of course deleted all the redirects the customer considered unnecessary, the remaining 700 redirects still have a delay of 1.2sec, this is (sort of) acceptable as a one time delay to load the webpage but its a big problem as a delay on web services, of which the site has many.
Is there some way to stop the redirects being triggered on Customer URLs? I tried patching my custom config to initialize the process before the redirect module but this had no effect on the delay. I can change the code myself but I would prefer an official answer to prevent accidental future overwrites.
Thanks!
I was having a similar requirement, we were overriding CheckForDirectMatch method and filtering some URL's
In CheckForDirectMatch
if (!IsValidPath(requestedPath)) return;
base.CheckForDirectMatch(db,requestedUrl,requestedPath,args);
private bool IsValidPath(string requestedPath)
{
var excludedUrlsList = Settings.ExcludedUrlsPrefix.Split(';');
if (excludedUrlsList.Any(q => !string.IsNullOrWhiteSpace(q) && requestedPath.Contains(q))) return false;
return true;
}
In sitecore config settings
<setting name="ExcludedUrlsPrefix" value="/blog/api/;/chat/api/;" />
not sure if someone has a better solution.
thanks, this will do nicely for now.
Just FYI for future visitors, this code worked better for me as an override:
public class RedirectProc: RedirectProcessor
{
public override void Process(HttpRequestArgs args)
{
var requestedPath = HttpContext.Current.Request.Url.AbsolutePath;
if (!IsValidPath(requestedPath)) return;
base.Process(args);
}
private bool IsValidPath(string requestedPath)
{
var excludedUrlsList = Sitecore.Configuration.Settings.GetSetting("ExcludedUrlsPrefix").Split(';');
if (excludedUrlsList.Any(q => !string.IsNullOrWhiteSpace(q) && requestedPath.Contains(q))) return false;
return true;
}
}
Just FYI for future visitors, this code worked better for me as an override:
public class RedirectProc: RedirectProcessor { public override void Process(HttpRequestArgs args) { var requestedPath = HttpContext.Current.Request.Url.AbsolutePath; if (!IsValidPath(requestedPath)) return; base.Process(args); } private bool IsValidPath(string requestedPath) { var excludedUrlsList = Sitecore.Configuration.Settings.GetSetting("ExcludedUrlsPrefix").Split(';'); if (excludedUrlsList.Any(q => !string.IsNullOrWhiteSpace(q) && requestedPath.Contains(q))) return false; return true; } }
this is great, we were having few other customizations hence overriding CheckForDirectMatch