Skip to content
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
4 changes: 2 additions & 2 deletions apps/web/app/api/releases/latest/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextResponse } from 'next/server'
import { latestRelease } from '@/lib/releases'

export const revalidate = 3600
export const revalidate = 60

/**
* Normalised latest-release metadata, so the download UI never has to know
Expand All @@ -15,5 +15,5 @@ export async function GET() {
{ headers: { 'Cache-Control': 'public, s-maxage=600' } },
)
}
return NextResponse.json(release, { headers: { 'Cache-Control': 'public, s-maxage=3600' } })
return NextResponse.json(release, { headers: { 'Cache-Control': 'public, s-maxage=60' } })
}
11 changes: 9 additions & 2 deletions apps/web/app/download/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ export const metadata: Metadata = {
// old while `install.sh`, which asks the GitHub API at run time, was handing
// out the current one.
//
// The fetch in latestRelease() keeps its own hourly cache, so per-request
// rendering costs a render and not a GitHub call.
// The fetch in latestRelease() keeps its own cache, so per-request rendering
// costs a render and not a GitHub call. That cache is 60s rather than an hour:
// a release is the one thing a visitor here is looking for, and v0.1.8 was
// published and downloadable while this page still offered v0.1.7. Next
// revalidates lazily -- on the first request after the window lapses, not on a
// timer -- so the ceiling is 60 GitHub calls an hour and the real number
// tracks traffic. Worth knowing before lowering it further: unauthenticated
// GitHub allows exactly 60 an hour per IP, and latestRelease() answers null on
// a refusal, which renders as no release at all.
export const dynamic = 'force-dynamic'

export default async function DownloadPage() {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/lib/releases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function latestRelease(): Promise<ReleaseInfo | null> {
try {
const response = await fetch(ENDPOINT, {
headers: { Accept: 'application/vnd.github+json' },
next: { revalidate: 3600 },
next: { revalidate: 60 },
})
// A repository with no tagged release yet answers 404. That is a normal
// state before launch, not an error worth surfacing to a visitor.
Expand Down
Loading