We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 56d373f commit 2c23a47Copy full SHA for 2c23a47
bff/server/SecurityHeadersDefinitions.cs
@@ -2,11 +2,17 @@
2
3
public static class SecurityHeadersDefinitions
4
{
5
+ private static HeaderPolicyCollection? policy;
6
+
7
public static HeaderPolicyCollection GetHeaderPolicyCollection(bool isDev, string? idpHost)
8
9
ArgumentNullException.ThrowIfNull(idpHost);
10
- var policy = new HeaderPolicyCollection()
11
+ // Avoid building a new HeaderPolicyCollection on every request for performance reasons.
12
+ // Where possible, cache and reuse HeaderPolicyCollection instances.
13
+ if (policy != null) return policy;
14
15
+ policy = new HeaderPolicyCollection()
16
.AddFrameOptionsDeny()
17
.AddContentTypeOptionsNoSniff()
18
.AddReferrerPolicyStrictOriginWhenCrossOrigin()
0 commit comments