@@ -12,12 +12,11 @@ public static class EndpointExtensions
1212{ public static void MapSitemapEndpoint ( this WebApplication app )
1313 {
1414 app . MapGet ( "/sitemap.xml" , async ( HttpContext context , IContentService contentService ) =>
15- {
16- // Enable output caching for sitemap
15+ { // Enable output caching for sitemap - extended to 6 hours
1716 context . Response . GetTypedHeaders ( ) . CacheControl = new Microsoft . Net . Http . Headers . CacheControlHeaderValue
1817 {
1918 Public = true ,
20- MaxAge = TimeSpan . FromHours ( 1 )
19+ MaxAge = TimeSpan . FromHours ( 6 )
2120 } ;
2221 // Define the XML namespace for the sitemap
2322 XNamespace ns = "http://www.sitemaps.org/schemas/sitemap/0.9" ;
@@ -111,21 +110,19 @@ public static class EndpointExtensions
111110 context . Response . ContentType = MediaTypeNames . Application . Xml ;
112111
113112 // Return the XML document as a string
114- return sitemap . ToString ( ) ;
115- } )
113+ return sitemap . ToString ( ) ; } )
116114 . CacheOutput ( policy => policy
117- . Expire ( TimeSpan . FromHours ( 1 ) )
115+ . Expire ( TimeSpan . FromHours ( 6 ) )
118116 . SetVaryByHost ( true )
119117 . Tag ( "sitemap" ) ) ;
120118 } public static void MapRssFeedEndpoint ( this WebApplication app )
121119 {
122120 app . MapGet ( "/feed.rss" , async ( HttpContext context , IContentService contentService ) =>
123- {
124- // Enable output caching for RSS feed
121+ { // Enable output caching for RSS feed - extended to 2 hours for better performance
125122 context . Response . GetTypedHeaders ( ) . CacheControl = new Microsoft . Net . Http . Headers . CacheControlHeaderValue
126123 {
127124 Public = true ,
128- MaxAge = TimeSpan . FromMinutes ( 30 )
125+ MaxAge = TimeSpan . FromHours ( 2 )
129126 } ; // Create the RSS feed XML document
130127 var rss = new XDocument (
131128 new XDeclaration ( "1.0" , "utf-8" , null ) ,
@@ -186,10 +183,9 @@ public static class EndpointExtensions
186183 }
187184
188185 // Return the XML document as a string
189- return rss . ToString ( ) ;
190- } )
186+ return rss . ToString ( ) ; } )
191187 . CacheOutput ( policy => policy
192- . Expire ( TimeSpan . FromMinutes ( 30 ) )
188+ . Expire ( TimeSpan . FromHours ( 2 ) )
193189 . SetVaryByHost ( true )
194190 . Tag ( "rss" ) ) ;
195191 }
0 commit comments