Skip to content
Snippets Groups Projects
Commit 80abbfdb authored by Florent Poittevin's avatar Florent Poittevin
Browse files

feat(ssr): share ssr cache between root and home

parent fc70429b
No related branches found
No related tags found
No related merge requests found
......@@ -60,6 +60,7 @@ const ssrRoutes: RequestOption[] = [
{
path: "/",
timeToLive: 600,
useCacheOfOtherPath: "/" + RoutesEnum.homePage,
},
{
path: "/" + RoutesEnum.homePage,
......@@ -127,6 +128,10 @@ const setRuntimeValueOnGlobalVariable: (req: any) => void = (req: any) => {
const generateCacheKey: (req: any) => string = req => {
let cacheKey = req.url;
const ssrRoute = ssrRoutes.find(r => r.path === req.url);
if (isNotNullNorUndefinedNorWhiteString(ssrRoute.useCacheOfOtherPath)) {
cacheKey = ssrRoute.useCacheOfOtherPath;
}
const languageHeader = window.navigator.language;
const languageCookie = CookieHelper.getItem(CookiePartialEnum.language);
const language = isNotNullNorUndefinedNorWhiteString(languageCookie) ? languageCookie : languageHeader;
......@@ -264,4 +269,5 @@ interface RequestOption {
path: string;
timeToLive?: number;
cacheForbidden?: boolean;
useCacheOfOtherPath?: string;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment