Ignore additional paths more easily and efficiently with this replacement for the IgnoreList processor in Sitecore's httpRequestBegin pipeline.
Sitecore is very eager to help. It wants to serve any request that that the application it receives. Sometimes, however, you may want Sitecore to let a request by so it can be processed by standard ASP.NET or other IIS modules. For example, you may have a legacy ASPX page that does not use Sitecore. Even more common these days is the need to use ASP.NET MVC bundling.
Out-of-the-box, Sitecore has a configuration setting named IgnoreUrlPrefixes that allows you to tell Sitecore to ignore certain requests. The value of the setting is a pipe delimited list of prefixes that Sitecore should ignore. The IgnoreList processor for the httpRequestBegin pipeline checks to see if any of the prefixes in the list match the current request. If it finds a match, it aborts the pipeline sending control back to the standard ASP.NET pipeline.
Forcing the ignore list into a single-valued configuration setting is somewhat problematic. Sitecore best practices dictate that we should always use patch files to modify configuration. However, you can’t simply add another prefix to the list in a patch file. You have to come up with a master list. The other alternative is to create your own ignore processor which can be patched in. This is the approach taken by FXM.
I have created a small module that fixes this issue. The PatchableIgnoreList utilizes Sitecore's Configuration Factory's ability to populate list properties to make the list patchable by multiple independent patch files. Here's the main patch file for PatchableIgnoreList:
And then additional prefixes can be added by any patch file like so:
Note that the desc attribute should be unique so that the patching system knows to insert the prefix rather than overwrite and existing one.
Bonus – Performance Boost
As I was looking at the decompiled code for the standard ignore list processor, I thought that it seemed rather inefficient. On every request, the processor iterates over the array of prefixes and checks if the requested URL starts with each prefix. It aborts as soon as it finds a match, but for requests that are not ignored (most of them), it must go through the whole list. Sure, there are only 10 prefixes in the array initially, but on a high traffic site, that could add up.
I decided to implement the PatchableIgnoreList with a trie to try to improve the performance. Benchmarking showed more than 20% improvement, on average, over the array-based implementation with only 10 prefixes. When the length of the prefix list is increased to 20, the trie-based implementation is over 50% faster.
The code and package are currently available on GitHub. It will (hopefully) be available on the Sitecore marketplace in the near future.
The PatchableIgnoreList module is now available on the Sitecore Marketplace.