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

[FEATURE]: actually specify cache control headers, especially for the b… #57

Merged
Merged
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
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