Conditional requests
ETag caching with ifNoneMatch and notModified.
listEvents and getEvent support ETag caching.
Pass a previous etag back as ifNoneMatch; a 304 resolves with
notModified: true and data: null, so you keep using your cached value:
const first = await client.getEvent('my-event')
const next = await client.getEvent('my-event', {
ifNoneMatch: first.etag ?? undefined,
})
if (next.notModified) {
// nothing changed: reuse first.data
}A tiny cache helper
import type { Event } from '@jetronticket/api'
const cache = new Map<string, { etag: string; data: Event }>()
async function getEventCached(slug: string): Promise<Event | null> {
const hit = cache.get(slug)
const result = await client.getEvent(slug, {
ifNoneMatch: hit?.etag,
})
if (result.notModified) return hit!.data
if (result.data && result.etag) {
cache.set(slug, { etag: result.etag, data: result.data })
}
return result.data
}This pairs well with polling. Refreshing an event page every minute costs a
304 with no body unless something actually changed.
Only reads are cacheable
Reservations and orders are never cached; ifNoneMatch exists only on
listEvents and getEvent.

