@@ -48,6 +48,7 @@ import {
4848 toClientConfig ,
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 '@dspace/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 > ;
@@ -333,7 +338,7 @@ function clientSideRender(req, res) {
333338 html = html . replace ( new RegExp ( REST_BASE_URL , 'g' ) , environment . rest . baseUrl ) ;
334339 }
335340
336- res . send ( html ) ;
341+ res . set ( 'Cache-Control' , 'no-cache, no-store' ) . send ( html ) ;
337342}
338343
339344
@@ -344,7 +349,11 @@ function clientSideRender(req, res) {
344349 */
345350function addCacheControl ( req , res , next ) {
346351 // instruct browser to revalidate
347- res . header ( 'Cache-Control' , environment . cache . control || 'max-age=604800' ) ;
352+ if ( environment . cache . noCacheFiles . includes ( req . originalUrl ) ) {
353+ res . header ( 'Cache-Control' , 'no-cache, no-store' ) ;
354+ } else {
355+ res . header ( 'Cache-Control' , environment . cache . control || 'max-age=604800' ) ;
356+ }
348357 next ( ) ;
349358}
350359
0 commit comments