Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace maxAge with ttl in LRU Cache #114

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 16
node-version: 18
cache: "yarn"

- name: Install dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as React from "react";
import { useStore } from "../../models/root-store";
import { DateFilter } from "./date-filter";
import { ParticipantsFilter } from "./participants-filter";
import { RegionFilter } from "./region-filter";
import { RegionFilterSection } from "./region-filter";
import { SeverityFilter } from "./severity-filter";

const FilterSection = ({ filter }) => {
Expand All @@ -16,7 +16,7 @@ const FilterSection = ({ filter }) => {
case "severity":
return <SeverityFilter {...filter} />;
case "region":
return <RegionFilter {...filter} />;
return <RegionFilterSection {...filter} />;
default:
return null;
}
Expand Down
5 changes: 4 additions & 1 deletion src/pages/api/rewrites/proxy-django-html-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import { djangoBaseUrl } from "../../../shared/django-helpers";
// Netlify runs inside Lambda functions, so page caching is not very efficient
// or reliable. However, if two requests hit the same function instance, this
// improves latency at a small memory footprint cost.

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const pageCache = new LRU<string, string>({
max: 100, // Capping the number of entries helps us avoid accidental memory overflows
maxAge: 1000 * 60 * 10, // 10 minutes
ttl: 1000 * 60 * 10, // 10 minutes
});

const transformHtmlByPathname: Record<string, (rawHtml: string) => string> = {
Expand Down