Skip to content

Commit

Permalink
feature: actually specify cache control headers, especially for the b…
Browse files Browse the repository at this point in the history
…raindump content page (#57)
  • Loading branch information
slackermorris authored Mar 5, 2023
1 parent a30a850 commit f9f4325
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
21 changes: 15 additions & 6 deletions app/routes/braindumps.list.$braindumpId.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useEffect, useState, Fragment, useMemo } from "react";
import { json } from "@remix-run/node";
import { HeadersFunction, json } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import notionClient from "~/integrations/notion";

Expand Down Expand Up @@ -155,11 +155,20 @@ export const loader = async ({
);
}

return json({
braindumpMeta: response,
braindumpContent: blocks,
braindumpContentReferences: references,
});
const headers = { "Cache-Control": "max-age=3600" };

return json(
{
braindumpMeta: response,
braindumpContent: blocks,
braindumpContentReferences: references,
},
{ headers }
);
};

export const headers: HeadersFunction = ({ loaderHeaders }) => {
return { "Cache-Control": loaderHeaders.get("Cache-Control")! };
};

export const links = () => {
Expand Down
6 changes: 4 additions & 2 deletions app/routes/braindumps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ const SummaryPanelWithBostockAnimation = () => {
);
};

export const headers: HeadersFunction = ({ loaderHeaders }) => {
return { "Cache-Control": loaderHeaders.get("Cache-Control")! };
export const headers: HeadersFunction = () => {
return {
"Cache-Control": "s-maxage=3600",
};
};

export default function BraindumpsIndex() {
Expand Down
2 changes: 1 addition & 1 deletion app/routes/braindumps/list.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { useEffect, useState } from "react";
import { useLoaderData, useCatch } from "@remix-run/react";
import { json } from "@remix-run/server-runtime";
Expand Down Expand Up @@ -73,7 +74,6 @@ export function CatchBoundary() {
}
}

// TODO: write note about how remix handles styles, particularly for a component library
export const links = () => {
return [
{
Expand Down

0 comments on commit f9f4325

Please sign in to comment.