Skip to content

Commit

Permalink
Add cache control headers for user preferences & comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Reynard-G committed Oct 14, 2024
1 parent f218b16 commit 1014c06
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/routes/app.$server.servers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
{
status: 200,
headers: {
"Cache-Control": "private, max-age=60",
"Cache-Control": "private, max-age=60", // 1 minute
},
},
);
Expand Down
2 changes: 1 addition & 1 deletion app/routes/app.$server.transactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
{
status: 200,
headers: {
"Cache-Control": "private, max-age=30",
"Cache-Control": "private, max-age=30", // 30 seconds
},
},
);
Expand Down
2 changes: 1 addition & 1 deletion app/routes/app.settings.account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
{
status: 200,
headers: {
"Cache-Control": "private, max-age=30",
"Cache-Control": "private, max-age=30", // 30 seconds
},
},
);
Expand Down
12 changes: 10 additions & 2 deletions app/routes/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AvatarImage } from "@radix-ui/react-avatar";
import { type LoaderFunctionArgs, redirect } from "@remix-run/node";
import { defer, type LoaderFunctionArgs, redirect } from "@remix-run/node";
import {
Link,
NavLink,
Expand Down Expand Up @@ -111,7 +111,15 @@ export async function loader({ request }: LoaderFunctionArgs) {
return redirect(`/app/${servers[0].shortName}/dashboard`);
}

return { user, servers, font: appearanceSettings.font };
return defer(
{ user, servers, font: appearanceSettings.font },
{
status: 200,
headers: {
"Cache-Control": "private, max-age=2592000", // 30 days
},
},
);
}

export default function App() {
Expand Down

0 comments on commit 1014c06

Please sign in to comment.