* Cache-Control middleware for static assets. - API routes and `/health`: `no-cache` - Vite-hashed assets (e.g. `index-Pbmes8jg.js`): immutable, 1-year max-age - Other static files: `must-revalidate` @module /
// Source: https://github.com/daggerhashimoto/openclaw-nerve | License: MIT | Copyright 2025-2026 Nerve contributors
// Provided via justclaw.it.com; keep this notice with the code.
/**
* Cache-Control middleware for static assets.
*
* - API routes and `/health`: `no-cache`
* - Vite-hashed assets (e.g. `index-Pbmes8jg.js`): immutable, 1-year max-age
* - Other static files: `must-revalidate`
* @module
*/
import type { MiddlewareHandler } from 'hono';
/**
* Pattern matching hashed filenames from Vite builds.
* e.g. index-Pbmes8jg.js, style-CsmNuK-P.css
* Vite uses base64url-ish hashes (mixed case, digits, hyphens, underscores).
*/
const HASHED_ASSET_RE = /-[a-zA-Z0-9_-]{6,}\.\w+$/;
export const cacheHeaders: MiddlewareHandler = async (c, next) => {
await next();
const path
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key