Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/api/routes/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import {
ScanCommand,
UpdateItemCommand,
} from "@aws-sdk/client-dynamodb";
import { EVENT_CACHED_DURATION, genericConfig } from "../../common/config.js";
import {
EVENT_CACHED_DURATION,
genericConfig,
STALE_IF_ERROR_CACHED_TIME,
} from "../../common/config.js";
import { marshall, unmarshall } from "@aws-sdk/util-dynamodb";
import {
BaseError,
Expand Down Expand Up @@ -118,7 +122,7 @@ const repeatOptions = ["weekly", "biweekly"] as const;
const zodIncludeMetadata = z.coerce.boolean().default(false).optional().meta({
description: "If true, include metadata for each event entry.",
});
export const CLIENT_HTTP_CACHE_POLICY = `public, max-age=${EVENT_CACHED_DURATION}, stale-while-revalidate=420, stale-if-error=3600`;
export const CLIENT_HTTP_CACHE_POLICY = `public, max-age=${EVENT_CACHED_DURATION}, stale-while-revalidate=${EVENT_CACHED_DURATION * 2}, stale-if-error=${STALE_IF_ERROR_CACHED_TIME}`;
export type EventRepeatOptions = (typeof repeatOptions)[number];

const baseSchema = z.object({
Expand Down
3 changes: 2 additions & 1 deletion src/api/routes/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
genericConfig,
notificationRecipients,
roleArns,
STALE_IF_ERROR_CACHED_TIME,
} from "common/config.js";
import { marshall, unmarshall } from "@aws-sdk/util-dynamodb";
import { buildAuditLogTransactPut } from "api/functions/auditLog.js";
Expand All @@ -48,7 +49,7 @@ import { retryDynamoTransactionWithBackoff } from "api/utils.js";
import { SKIP_EXTERNAL_ORG_LEAD_UPDATE } from "common/overrides.js";
import { AvailableSQSFunctions, SQSPayload } from "common/types/sqsMessage.js";

export const CLIENT_HTTP_CACHE_POLICY = `public, max-age=${ORG_DATA_CACHED_DURATION}, stale-while-revalidate=${Math.floor(ORG_DATA_CACHED_DURATION * 1.1)}, stale-if-error=3600`;
export const CLIENT_HTTP_CACHE_POLICY = `public, max-age=${ORG_DATA_CACHED_DURATION}, stale-while-revalidate=${ORG_DATA_CACHED_DURATION * 2}, stale-if-error=${STALE_IF_ERROR_CACHED_TIME}`;

const organizationsPlugin: FastifyPluginAsync = async (fastify, _options) => {
fastify.register(rateLimiter, {
Expand Down
1 change: 1 addition & 0 deletions src/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ const roleArns = {
};

export const EVENT_CACHED_DURATION = 120;
export const STALE_IF_ERROR_CACHED_TIME = 86400 // 1 day;

type NotificationRecipientsType = {
[env in RunEnvironment]: {
Expand Down
Loading