feat: smooth same-origin page changes

Cache versioned styles, images, and scripts so repeat clicks do not wait on them, crossfade navigations while the chrome stays put, and prefetch ordinary links on hover.
This commit is contained in:
blake committed 2026-10-20 13:17:27 -05:00
1 parent 5e0e4a55a8
commit 747e6e25e0
8 files changed
+236 -36

No files matched your search

+4 -1
View File
@@ -24,7 +24,7 @@ export const PERMISSIONS_POLICY = 'camera=(), microphone=(), geolocation=(), pay
export const STRICT_TRANSPORT_SECURITY = 'max-age=31536000';
/** HSTS is sent only when BASE_URL is https. A browser ignores it over http. */
export function securityHeaders(options: { https: boolean }): MiddlewareHandler {
export function securityHeaders(options: { https: boolean; speculationRules?: string }): MiddlewareHandler {
return async (c, next) => {
await next();
c.header('Content-Security-Policy', CONTENT_SECURITY_POLICY);
@@ -32,5 +32,8 @@ export function securityHeaders(options: { https: boolean }): MiddlewareHandler
c.header('X-Content-Type-Options', 'nosniff');
c.header('Permissions-Policy', PERMISSIONS_POLICY);
if (options.https) c.header('Strict-Transport-Security', STRICT_TRANSPORT_SECURITY);
if (options.speculationRules && (c.res.headers.get('content-type') ?? '').includes('text/html')) {
c.header('Speculation-Rules', `"${options.speculationRules}"`);
}
};
}