Skip to content

Commit

Permalink
add cache control header
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Graves committed Sep 25, 2023
1 parent ab5f703 commit 15c3175
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@notionhq/client/api-endpoints": "npm:@notionhq/[email protected]/build/src/api-endpoints"
},
"tasks": {
"dev": "deno run --allow-read --allow-net --watch server/main.ts",
"server": "deno run --allow-read --allow-net --watch server/main.ts",
"sync": "deno run --allow-read --allow-write --allow-env --allow-net sync/main.ts"
}
}
8 changes: 7 additions & 1 deletion server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ Deno.serve((req: Request) => {

if (pathname === "/robots.txt") return serveFile(req, "static/robots.txt");
if (pathname === "/favicon.ico") return serveFile(req, "static/favicon.ico");
if (pathname.startsWith("/static")) return serveDir(req, { fsRoot: "static", urlRoot: "static" });
if (pathname.startsWith("/static")) {
return serveDir(req, {
fsRoot: "static",
urlRoot: "static",
headers: ["cache-control:max-age=31536000"] // 1 year
});
}

if (pathname === "/") {
return new Response(home.document(), {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions server/templates/home.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Page } from "./page.ts";
import { Page } from "../page.ts";

export const home = new Page();

home.render = () => {
return home.html`
<h1>Home</h1>
<h1>Home Change 1</h1>
<p>
<a href="/about">About</a>
</p>
Expand Down

0 comments on commit 15c3175

Please sign in to comment.