When we grew PlumbDraft's library of US imperial residential CAD floor plans from 12 templates to 48+ (spanning detached ADUs, barndominiums, pole barn shops, garages, kitchens, and bathrooms), we hit two quiet performance and SEO problems at the exact same time:
- Our
/templatesSSR HTML ballooned past 1.5 MB. Every template card rendered a vector floor plan preview inline viadata:image/svg+xml;utf8,.... Multiply 48 detailed architectural blueprints (walls, door swing arcs, window mullions, cabinets, furniture, dimension chains) by ~30 KB each, and every single page load shipped a massive HTML document before the browser even started painting. - Google Image Search could not index a single blueprint. Search crawlers ignore
data:URIs for image indexing, and OpenGraph / Image Sitemap specs both require real crawlablehttps://image URLs. For a visual query like"20x20 garage conversion floor plan"or"30x40 barndominium floor plan", being invisible in Google Image Search meant leaving half the page-one real estate on the table.
Here is the exact 40-line architecture we shipped on SvelteKit + Cloudflare Workers to cut SSR HTML by ~93% (down to ~107 KB), make every blueprint edge-cacheable with zero cookies, and feed Google a clean Image Sitemap.
Step 1: Turn Inline CAD SVGs Into Real Deterministic Image Endpoints
Instead of serializing SVG strings into +page.server.ts props and stuffing them into <img src="data:image/svg+xml,...">, we added a dedicated SvelteKit server route at src/routes/templates/[slug]/blueprint.svg/+server.ts:
import { error } from '@sveltejs/kit'; import type { RequestHandler } from './$types'; import { compileFloorPlan, exportFloorPlanSvg, getTemplateById, getTemplateGuideBySlug } from '#lib/cad/index.js'; export const GET: RequestHandler = async ({ params, url }) => { const guide = getTemplateGuideBySlug(params.slug); if (!guide) { error(404, 'Template blueprint not found'); } const template = getTemplateById(guide.templateId); if (!template) { error(404, 'Template definition not found'); } const isThumb = url.searchParams.get('thumb') === '1'; const compiled = compileFloorPlan(template.plan); const svgMarkup = exportFloorPlanSvg(compiled.plan, { watermark: false, includeTitleBlock: !isThumb, showDimensions: !isThumb, showFurniture: true, showGrid: false }); return new Response(svgMarkup, { status: 200, headers: { 'Content-Type': 'image/svg+xml; charset=utf-8', 'Cache-Control': 'public, max-age=86400, s-maxage=86400', 'X-Content-Type-Options': 'nosniff' } }); }; Notice the ?thumb=1 switch:
- Gallery cards (
/templates) request/templates/[slug]/blueprint.svg?thumb=1withloading="lazy"anddecoding="async", stripping heavy title blocks and exterior dimension text that become unreadable at card scale. - Individual template pages (
/templates/[slug]) and Google Image Sitemaps reference the full crisp/templates/[slug]/blueprint.svgwith full imperial dimension chains and title blocks.
No headless browser, no PNG build pipeline, no R2 object sync bugs: the moment a new floor plan template lands in src/lib/cad/templates.ts, its vector blueprint URL is live on the edge.
Step 2: The Hidden Cloudflare CDN Trap — Set-Cookie Kills Edge Caching
If your SvelteKit hooks.server.ts issues a guest session cookie (so anonymous visitors can start drafting in a browser CAD studio without creating an account), watch out: by default, hooks run on server routes too.
If a response sends Set-Cookie: __Host-guest=... alongside Cache-Control: public, s-maxage=86400, Cloudflare CDN refuses to cache it (cf-cache-status: DYNAMIC) so it never leaks one user's session cookie to another visitor.
We guard our auth/session middleware with an explicit isCookielessPath() helper in src/lib/server/auth.ts:
export function isCookielessPath(pathname: string): boolean { if ( pathname === '/robots.txt' || pathname === '/sitemap.xml' || pathname === '/llms.txt' || pathname === '/llms-full.txt' || pathname === '/mcp' || pathname.startsWith('/.well-known/') || pathname.endsWith('/blueprint.svg') ) { return true; } return false; } When isCookielessPath(pathname) returns true, hooks.server.ts skips guest cookie minting completely. Every /templates/[slug]/blueprint.svg request returns:
- Zero
Set-Cookieheaders Content-Type: image/svg+xml; charset=utf-8Cache-Control: public, max-age=86400, s-maxage=86400X-Content-Type-Options: nosniff
Even better: we assert that exact invariant in our Vitest suite so a future middleware refactor can never silently re-introduce cookies on public blueprint assets.
Step 3: Wire Every Blueprint Into sitemap.xml and ImageObject JSON-LD
Once every template has a real crawlable HTTPS image URL, wiring Google Image Sitemaps takes ten lines in src/routes/sitemap.xml/+server.ts:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"> <url> <loc>https://www.plumbdraft.com/templates/20x20-garage-conversion-adu</loc> <lastmod>2026-12-02</lastmod> <changefreq>weekly</changefreq> <priority>0.8</priority> <image:image> <image:loc>https://www.plumbdraft.com/templates/20x20-garage-conversion-adu/blueprint.svg</image:loc> <image:title>20x20 Garage Conversion ADU Floor Plan Blueprint</image:title> <image:caption>Scaled US imperial 2D architectural floor plan for a 20x20 detached garage conversion ADU (400 sq ft) with dimensions and fixtures.</image:caption> </image:image> </url> </urlset> On each template detail page, we pair that with descriptive alt text on the <img> element and structured ImageObject JSON-LD pointing to the exact same blueprint.svg URL.
Measured Before vs. After
| Metric | Before (Inline Data-URI SVGs) | After (Cookieless /blueprint.svg Endpoint) |
|---|---|---|
/templates SSR HTML size | ~1,520 KB | 107 KB (-93%) |
Set-Cookie on blueprint images | N/A (inlined) | None (0 headers) |
Edge cacheable (s-maxage=86400) | No | Yes |
| Google Image Sitemap entries | 0 | All template blueprints indexed |
| Pre-rendered PNG storage required | None | None (deterministic on-the-fly vector CAD) |
If you want to inspect the live result—or open any blueprint directly in the interactive 2D/3D browser CAD studio with live IRC/NKBA clearance checks and framing takeoffs—check out the PlumbDraft US Imperial Floor Plan Template Library (free to customize in your browser with no signup required; AI agents can also fetch every template directly via our hosted MCP server at https://www.plumbdraft.com/mcp).
