Skip to content

Commit

Permalink
Use Cache-control: private for fridge index
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Jun 25, 2024
1 parent 4c83f3d commit 043df6c
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/fridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ const CACHE_CONTROL_3DAYS = cacheControl(3);

export async function fridgeShabbat(ctx) {
if (ctx.request.path.startsWith('/fridge')) {
const q = processCookieAndQuery(ctx.cookies.get('C'), {}, ctx.request.query);
const location = getLocationFromQuery(ctx.db, q);
q['city-typeahead'] = location && location.geo !== 'pos' ? location.getName() : '';
return ctx.render('fridge-index', {
q,
langNames,
});
return fridgeIndex(ctx);
}
const p = makeProperties(ctx);
ctx.lastModified = ctx.launchDate;
Expand All @@ -32,6 +26,21 @@ export async function fridgeShabbat(ctx) {
return ctx.render('fridge', p);
}

function fridgeIndex(ctx) {
const cookieStr = ctx.cookies.get('C');
let q = ctx.request.query;
if (cookieStr) {
ctx.set('Cache-Control', 'private');
q = processCookieAndQuery(cookieStr, {}, ctx.request.query);
const location = getLocationFromQuery(ctx.db, q);
q['city-typeahead'] = location && location.geo !== 'pos' ? location.getName() : '';
}
return ctx.render('fridge-index', {
q,
langNames,
});
}

/**
* @param {Koa.ParameterizedContext<Koa.DefaultState, Koa.DefaultContext>} ctx
* @return {Object}
Expand Down

0 comments on commit 043df6c

Please sign in to comment.