add server cache

This commit is contained in:
MuslemRahimi 2024-06-09 10:46:34 +02:00
parent 26c028e4ac
commit 5da5ded55a
3 changed files with 12 additions and 14 deletions

View File

@ -61,7 +61,7 @@ async function fetchPortfolio(fastifyURL, userId)
return output return output
} }
export const load = async ({ params, locals}) => { export const load = async ({ params, locals, setHeaders}) => {
const userRegion = locals.region?.split("::")[0]; const userRegion = locals.region?.split("::")[0];
@ -102,11 +102,11 @@ export const load = async ({ params, locals}) => {
getUserPortfolio, getUserPortfolio,
] = await Promise.all(promises); ] = await Promise.all(promises);
/*
setHeaders({ setHeaders({
'cache-control': 'public, max-age=500' 'cache-control': 'public, max-age=300'
}); });
*/
return { return {
getCryptoProfile, getCryptoProfile,

View File

@ -85,7 +85,7 @@ async function fetchPortfolio(fastifyURL, userId)
return output return output
} }
export const load = async ({ params, locals}) => { export const load = async ({ params, locals, setHeaders}) => {
const userRegion = locals.region?.split("::")[0]; const userRegion = locals.region?.split("::")[0];
@ -135,11 +135,11 @@ const promises = [
getUserPortfolio, getUserPortfolio,
] = await Promise.all(promises); ] = await Promise.all(promises);
/*
setHeaders({ setHeaders({
'cache-control': 'public, max-age=500' 'cache-control': 'public, max-age=300'
}); });
*/
return { return {
getETFProfile, getETFProfile,

View File

@ -115,7 +115,7 @@ async function fetchCommunitySentiment(pb, ticker, cookies)
} }
export const load = async ({ params, locals, cookies}) => { export const load = async ({ params, locals, cookies, setHeaders}) => {
const userRegion = locals?.region?.split("::")[0]; const userRegion = locals?.region?.split("::")[0];
@ -174,17 +174,15 @@ export const load = async ({ params, locals, cookies}) => {
getCommunitySentiment, getCommunitySentiment,
] = await Promise.all(promises); ] = await Promise.all(promises);
/*
setHeaders({ setHeaders({
'cache-control': 'public, max-age=500' 'cache-control': 'public, max-age=300' //Cache data for 5 min
}); });
*/
return { return {
getFairPrice, getFairPrice,
getSimilarStock, getSimilarStock,
//getPricePrediction,
//getTradingSignals,
getStockDeck, getStockDeck,
getCorrelation, getCorrelation,
getAnalystRating, getAnalystRating,