Skip to content

Commit

Permalink
Move 304 Freshness check for holiday pages after redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Nov 26, 2024
1 parent 524dae7 commit 1148408
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/holidayApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import {holidayPdf} from './holidayPdf.js';
import {holidayYearIndex} from './holidayYearIndex.js';

export async function holidayApp(ctx) {
ctx.lastModified = ctx.launchDate;
ctx.status = 200;
if (ctx.fresh) {
ctx.status = 304;
return;
}
const rpath = ctx.request.path;
ctx.state.il = ctx.request.query.i === 'on';
if (rpath === '/holidays/') {
Expand Down
6 changes: 6 additions & 0 deletions src/holidayDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ export async function holidayDetail(ctx) {
httpRedirect(ctx, `/holidays/${holidayAnchor}`);
return;
}
ctx.lastModified = ctx.launchDate;
ctx.status = 200;
if (ctx.fresh) {
ctx.status = 304;
return;
}
const idx = year ? multiYearBegin.findIndex((ev) => ev === next.event) : -1;
const prevNext = {};
if (idx !== -1) {
Expand Down
6 changes: 6 additions & 0 deletions src/holidayIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ export async function holidayMainIndex(ctx) {
if (hyear < 3762 || hyear > 9995) {
return httpRedirect(ctx, `/holidays/?redir=year`);
}
ctx.lastModified = ctx.launchDate;
ctx.status = 200;
if (ctx.fresh) {
ctx.status = 304;
return;
}
const tishrei1 = new HDate(1, 'Tishrei', hyear);
const items = {};
for (const catId of Object.keys(categories)) {
Expand Down
6 changes: 6 additions & 0 deletions src/holidayYearIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ export async function holidayYearIndex(ctx) {
} else if (yearNum < 1 || yearNum > 9999) {
throw createError(400, `Sorry, can't display holidays for year ${year}`);
}
ctx.lastModified = ctx.launchDate;
ctx.status = 200;
if (ctx.fresh) {
ctx.status = 304;
return;
}
const isHebrewYear = yearNum >= 3761 || year.indexOf('-') !== -1;
const calendarYear = makeCalendarYear(isHebrewYear, yearNum);
const il = ctx.state.il;
Expand Down

0 comments on commit 1148408

Please sign in to comment.