@@ -52,6 +52,7 @@ import { ServerAppModule } from './src/main.server';
5252import { buildAppConfig } from './src/config/config.server' ;
5353import { APP_CONFIG , AppConfig } from './src/config/app-config.interface' ;
5454import { extendEnvironmentWithAppConfig } from './src/config/config.util' ;
55+ import { ServerHashedFileMapping } from './src/modules/dynamic-hash/hashed-file-mapping.server' ;
5556import { logStartupMessage } from './startup-message' ;
5657import { TOKENITEM } from './src/app/core/auth/models/auth-token-info.model' ;
5758import { SsrExcludePatterns } from './src/config/universal-config.interface' ;
@@ -68,7 +69,11 @@ const indexHtml = join(DIST_FOLDER, 'index.html');
6869
6970const cookieParser = require ( 'cookie-parser' ) ;
7071
71- const appConfig : AppConfig = buildAppConfig ( join ( DIST_FOLDER , 'assets/config.json' ) ) ;
72+ const configJson = join ( DIST_FOLDER , 'assets/config.json' ) ;
73+ const hashedFileMapping = new ServerHashedFileMapping ( DIST_FOLDER , 'index.html' ) ;
74+ const appConfig : AppConfig = buildAppConfig ( configJson , hashedFileMapping ) ;
75+ appConfig . themes . forEach ( themeConfig => hashedFileMapping . addThemeStyle ( themeConfig . name , themeConfig . prefetch ) ) ;
76+ hashedFileMapping . save ( ) ;
7277
7378// cache of SSR pages for known bots, only enabled in production mode
7479let botCache : LRU < string , any > ;
@@ -319,7 +324,7 @@ function clientSideRender(req, res) {
319324 html = html . replace ( new RegExp ( REST_BASE_URL , 'g' ) , environment . rest . baseUrl ) ;
320325 }
321326
322- res . send ( html ) ;
327+ res . set ( 'Cache-Control' , 'no-cache, no-store' ) . send ( html ) ;
323328}
324329
325330
@@ -330,7 +335,11 @@ function clientSideRender(req, res) {
330335 */
331336function addCacheControl ( req , res , next ) {
332337 // instruct browser to revalidate
333- res . header ( 'Cache-Control' , environment . cache . control || 'max-age=604800' ) ;
338+ if ( environment . cache . noCacheFiles . includes ( req . originalUrl ) ) {
339+ res . header ( 'Cache-Control' , 'no-cache, no-store' ) ;
340+ } else {
341+ res . header ( 'Cache-Control' , environment . cache . control || 'max-age=604800' ) ;
342+ }
334343 next ( ) ;
335344}
336345
0 commit comments