File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
src/Umbraco.Web.Common/DependencyInjection Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1
1
using System . Collections . Generic ;
2
2
using System . Threading . Tasks ;
3
+ using Microsoft . AspNetCore . Http ;
3
4
using Microsoft . Extensions . Configuration ;
4
5
using Microsoft . Extensions . DependencyInjection ;
5
6
using Microsoft . Extensions . Options ;
7
+ using Microsoft . Net . Http . Headers ;
6
8
using SixLabors . ImageSharp . Web . Caching ;
7
9
using SixLabors . ImageSharp . Web . Commands ;
8
10
using SixLabors . ImageSharp . Web . DependencyInjection ;
@@ -48,6 +50,24 @@ public static IServiceCollection AddUmbracoImageSharp(this IUmbracoBuilder build
48
50
context . Commands . Remove ( ResizeWebProcessor . Height ) ;
49
51
}
50
52
53
+ return Task . CompletedTask ;
54
+ } ;
55
+ options . OnBeforeSaveAsync = _ => Task . CompletedTask ;
56
+ options . OnProcessedAsync = _ => Task . CompletedTask ;
57
+ options . OnPrepareResponseAsync = context =>
58
+ {
59
+ // Change Cache-Control header when cache buster value is present
60
+ if ( context . Request . Query . ContainsKey ( "rnd" ) )
61
+ {
62
+ var headers = context . Response . GetTypedHeaders ( ) ;
63
+
64
+ var cacheControl = headers . CacheControl ;
65
+ cacheControl . MustRevalidate = false ;
66
+ cacheControl . Extensions . Add ( new NameValueHeaderValue ( "immutable" ) ) ;
67
+
68
+ headers . CacheControl = cacheControl ;
69
+ }
70
+
51
71
return Task . CompletedTask ;
52
72
} ;
53
73
} )
You can’t perform that action at this time.
0 commit comments