@@ -65,6 +65,19 @@ foreach ($Module in $Modules) {
6565$SwCoreModules.Stop ()
6666$Timings [' CoreModules' ] = $SwCoreModules.Elapsed.TotalMilliseconds
6767
68+ # Load CIPPHttpClient assembly once at startup for all worker types
69+ $SwCIPPHttp = [System.Diagnostics.Stopwatch ]::StartNew()
70+ try {
71+ $CIPPHttpDllPath = Join-Path $env: CIPPRootPath ' Shared\CIPPHttp\bin\CIPPHttp.dll'
72+ if (-not ([System.AppDomain ]::CurrentDomain.GetAssemblies().Location -contains $CIPPHttpDllPath )) {
73+ $null = [Reflection.Assembly ]::LoadFile($CIPPHttpDllPath )
74+ }
75+ } catch {
76+ Write-Warning " CIPPHttpClient failed to load: $ ( $_.Exception.Message ) "
77+ }
78+ $SwCIPPHttp.Stop ()
79+ $Timings [' CIPPHttpClient' ] = $SwCIPPHttp.Elapsed.TotalMilliseconds
80+
6881# Pre-load function permissions cache once per worker startup (fallback remains in runtime code)
6982$SwPermissionsPreload = [System.Diagnostics.Stopwatch ]::StartNew()
7083if (-not $global :CIPPFunctionPermissions ) {
@@ -263,19 +276,6 @@ if ($WorkerType -ne 'HttpOnly') {
263276 $Timings [' CronosAssembly' ] = $SwCronos.Elapsed.TotalMilliseconds
264277}
265278
266- # Load CIPPHttpClient assembly once at startup for all worker types
267- $SwCIPPHttp = [System.Diagnostics.Stopwatch ]::StartNew()
268- try {
269- $CIPPHttpDllPath = Join-Path $env: CIPPRootPath ' Shared\CIPPHttp\bin\CIPPHttp.dll'
270- if (-not ([System.AppDomain ]::CurrentDomain.GetAssemblies().Location -contains $CIPPHttpDllPath )) {
271- $null = [Reflection.Assembly ]::LoadFile($CIPPHttpDllPath )
272- }
273- } catch {
274- Write-Warning " CIPPHttpClient failed to load: $ ( $_.Exception.Message ) "
275- }
276- $SwCIPPHttp.Stop ()
277- $Timings [' CIPPHttpClient' ] = $SwCIPPHttp.Elapsed.TotalMilliseconds
278-
279279$TotalStopwatch.Stop ()
280280$Timings [' Total' ] = $TotalStopwatch.Elapsed.TotalMilliseconds
281281
0 commit comments