Make pages load fast on mobile
- Compress responses: page scripts and styles once (brotli or gzip, in memory) and cached immutable; pages and API JSON gzipped as they stream - Service worker serves content-named assets cache-first - Load the models modal's data when it opens (cached in localStorage) instead of shipping the model catalog in every conversation page - Lazy-load the Tiptap composer and memoize thread messages - Import lucide icons directly; twui 0.1.4 drops by-name icons from Button - bun run start builds the pages minified before serving Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
type Params = {
|
||||
content_type?: string | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether a response of this content type is text worth compressing:
|
||||
* pages, scripts, styles, JSON, SVG and the like. Media, fonts and
|
||||
* streams (`text/event-stream`) are left as they are.
|
||||
*/
|
||||
export default function isCompressibleType({ content_type }: Params): boolean {
|
||||
const type = content_type?.split(";")[0]?.trim().toLowerCase();
|
||||
|
||||
if (!type || type == "text/event-stream") return false;
|
||||
if (type.startsWith("text/")) return true;
|
||||
|
||||
return /^application\/(javascript|json|manifest\+json|xml|[\w.-]+\+json|[\w.-]+\+xml)$/.test(type) ||
|
||||
type == "image/svg+xml";
|
||||
}
|
||||
Reference in New Issue
Block a user