My ASP.NET MVC 3 project slows down the scan after adding the 51Degrees mobile device discovery library. The 51Degrees log file, defined by <log logFile="~/bin/App_Data/51Log.txt" logLevel="Info" /> in the <fiftyOne> section, shows that the device library is reloaded for each request, adding a delay of 2-3 seconds for each request:
2011-10-22T14:17:34.9863774Z - 8436 - Info - Loaded 14691 devices using 11640 strings in 1882ms 2011-10-22T14:17:50.8442844Z - 8436 - Info - Loaded 14691 devices using 11640 strings in 1820ms 2011-10-22T14:17:57.2756523Z - 8436 - Info - Loaded 14691 devices using 11640 strings in 1928ms 2011-10-22T14:18:01.0488681Z - 8436 - Info - Loaded 14691 devices using 11640 strings in 1886ms 2011-10-22T14:18:04.6790757Z - 8436 - Info - Loaded 14691 devices using 11640 strings in 1862ms
In addition, setting <fiftyOne> <log ... logLevel="Debug"> to web.config raises the following exception at startup:
Storage scopes cannot be created when _AppStart is executing.
MVC 4 Update
Everything works fine if I create an empty ASP.NET MVC 4 application and add the new NuGet 51Degrees 2.0.3.2 package. As expected, the log reflects that binary data is downloaded only once, despite numerous requests (51Degrees.mobi-Lite-2012.01.05.dat).
Carefully optimistic, I copied all of my main MVC 3 project project to a new ASP.NET MVC 4 project and re-added the last 51Degrees package, but the problem persists. There must be incompatibility with one of my packages or a weird setup.
The log shows that the library is reloading for each request:
2012-01-18T11:50:02.5026920Z - 11928 - Info - Creating provider from binary data file '~\App_Data\51Degrees.mobi-Lite-2012.01.05.dat'. 2012-01-18T11:50:02.8137098Z - 11928 - Info - Created provider from binary data file '~\App_Data\51Degrees.mobi-Lite-2012.01.05.dat'. 2012-01-18T11:50:07.7419917Z - 11928 - Info - Creating provider from binary data file '~\App_Data\51Degrees.mobi-Lite-2012.01.05.dat'. 2012-01-18T11:50:08.0170074Z - 11928 - Info - Created provider from binary data file '~\App_Data\51Degrees.mobi-Lite-2012.01.05.dat'. 2012-01-18T11:50:10.4191448Z - 11928 - Info - Creating provider from binary data file '~\App_Data\51Degrees.mobi-Lite-2012.01.05.dat'. 2012-01-18T11:50:10.7251623Z - 11928 - Info - Created provider from binary data file '~\App_Data\51Degrees.mobi-Lite-2012.01.05.dat'.
The delay is much less than the XML data file (300 ms versus 3000 ms), but it still causes a noticeable delay.
The files of the two 51Degrees.mobi.config projects are identical, and in my web.config this is the module I downloaded:
<modules> <remove name="Detector"/> <add name="Detector" type="FiftyOne.Foundation.Mobile.Detection.DetectorModule, FiftyOne.Foundation"/> </modules>
What can cause a 51Degrees library to reload on each request?