@@ -47,6 +47,7 @@ import {
4747 AppConfig ,
4848} from './src/config/app-config.interface' ;
4949import { extendEnvironmentWithAppConfig } from './src/config/config.util' ;
50+ import { ServerHashedFileMapping } from './src/modules/dynamic-hash/hashed-file-mapping.server' ;
5051import { logStartupMessage } from './startup-message' ;
5152import { TOKENITEM } from '@dspace/core/auth/models/auth-token-info.model' ;
5253import { CommonEngine } from '@angular/ssr/node' ;
@@ -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 : LRUCache < string , any > ;
@@ -324,7 +329,7 @@ function clientSideRender(req, res) {
324329 html = html . replace ( new RegExp ( REST_BASE_URL , 'g' ) , environment . rest . baseUrl ) ;
325330 }
326331
327- res . send ( html ) ;
332+ res . set ( 'Cache-Control' , 'no-cache, no-store' ) . send ( html ) ;
328333}
329334
330335
@@ -335,7 +340,11 @@ function clientSideRender(req, res) {
335340 */
336341function addCacheControl ( req , res , next ) {
337342 // instruct browser to revalidate
338- res . header ( 'Cache-Control' , environment . cache . control || 'max-age=604800' ) ;
343+ if ( environment . cache . noCacheFiles . includes ( req . originalUrl ) ) {
344+ res . header ( 'Cache-Control' , 'no-cache, no-store' ) ;
345+ } else {
346+ res . header ( 'Cache-Control' , environment . cache . control || 'max-age=604800' ) ;
347+ }
339348 next ( ) ;
340349}
341350
0 commit comments