Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Causing Delay for custom APIs #56

Open
lownlazy opened this issue Sep 9, 2019 · 4 comments
Open

Causing Delay for custom APIs #56

lownlazy opened this issue Sep 9, 2019 · 4 comments

Comments

@lownlazy
Copy link

lownlazy commented Sep 9, 2019

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!

@BhanuNexus
Copy link
Contributor

BhanuNexus commented Sep 9, 2019

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.

@lownlazy
Copy link
Author

thanks, this will do nicely for now.

@lownlazy
Copy link
Author

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;
        }
    }

@BhanuNexus
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants