@@ -48,6 +48,7 @@ import {
4848 AppConfig ,
4949} from './src/config/app-config.interface' ;
5050import { extendEnvironmentWithAppConfig } from './src/config/config.util' ;
51+ import { ServerHashedFileMapping } from './src/modules/dynamic-hash/hashed-file-mapping.server' ;
5152import { logStartupMessage } from './startup-message' ;
5253import { TOKENITEM } from './src/app/core/auth/models/auth-token-info.model' ;
5354import { CommonEngine } from '@angular/ssr/node' ;
@@ -69,7 +70,11 @@ const indexHtml = join(DIST_FOLDER, 'index.html');
6970
7071const cookieParser = require ( 'cookie-parser' ) ;
7172
72- const appConfig : AppConfig = buildAppConfig ( join ( DIST_FOLDER , 'assets/config.json' ) ) ;
73+ const configJson = join ( DIST_FOLDER , 'assets/config.json' ) ;
74+ const hashedFileMapping = new ServerHashedFileMapping ( DIST_FOLDER , 'index.html' ) ;
75+ const appConfig : AppConfig = buildAppConfig ( configJson , hashedFileMapping ) ;
76+ appConfig . themes . forEach ( themeConfig => hashedFileMapping . addThemeStyle ( themeConfig . name , themeConfig . prefetch ) ) ;
77+ hashedFileMapping . save ( ) ;
7378
7479// cache of SSR pages for known bots, only enabled in production mode
7580let botCache : LRUCache < string , any > ;
@@ -329,7 +334,7 @@ function clientSideRender(req, res) {
329334 html = html . replace ( new RegExp ( REST_BASE_URL , 'g' ) , environment . rest . baseUrl ) ;
330335 }
331336
332- res . send ( html ) ;
337+ res . set ( 'Cache-Control' , 'no-cache, no-store' ) . send ( html ) ;
333338}
334339
335340
@@ -340,7 +345,11 @@ function clientSideRender(req, res) {
340345 */
341346function addCacheControl ( req , res , next ) {
342347 // instruct browser to revalidate
343- res . header ( 'Cache-Control' , environment . cache . control || 'max-age=604800' ) ;
348+ if ( environment . cache . noCacheFiles . includes ( req . originalUrl ) ) {
349+ res . header ( 'Cache-Control' , 'no-cache, no-store' ) ;
350+ } else {
351+ res . header ( 'Cache-Control' , environment . cache . control || 'max-age=604800' ) ;
352+ }
344353 next ( ) ;
345354}
346355
0 commit comments