Skip to content

Issue 269#517

Open
binayyub4211 wants to merge 17 commits into
rinafcode:mainfrom
binayyub4211:issue-269
Open

Issue 269#517
binayyub4211 wants to merge 17 commits into
rinafcode:mainfrom
binayyub4211:issue-269

Conversation

@binayyub4211
Copy link
Copy Markdown
Contributor

Closes #341

What was done
Implemented global CDN delivery for all static assets (images, fonts) with automatic SemVer-based URL versioning and aggressive 1-year cache headers enforced across three major deployment platforms.

Changes
New files:

src/utils/cdn.ts — Central CDN utility. Maps any asset path, remote URL, or require() module ID to a versioned CDN URL (https://cdn.teachlink.com/…?v=1.8.0). Handles URL sanitization, assets/ prefix stripping, and CDN URL version bumping.
vercel.json — Enforces Cache-Control: public, max-age=31536000, immutable for /assets/* on Vercel.
netlify.toml — Same 1-year cache header for Netlify deployments.
firebase.json — Same cache header for Firebase Hosting (dist/assets/**).
docs/cdn-strategy.md — Full CDN strategy documentation covering Cloudflare, AWS CloudFront, Vercel, Netlify, Firebase configs; curl verification commands; and performance monitoring KPIs (Cache Hit Ratio ≥ 95%, LCP, TTFB).
src/tests/utils/cdn.test.ts — 16 unit tests covering isCDNUrl, getCDNAssetUrl (null inputs, remote URLs, relative paths, assets/ prefix stripping, asset module ID resolution, error handling), and getCDNFontUrl.
Modified files:

src/components/ui/CachedImage.tsx — All image URIs are now rewritten through getCDNAssetUrl() before being passed to ImageCache.prefetchImages and expo-image. Local and remote paths are transparently mapped to the CDN origin.
src/services/fontService.ts — String font sources in loadFont() are routed through getCDNAssetUrl(), ensuring dynamically loaded fonts are fetched from CDN with cache busting on version bumps.
src/tests/components/imageCache.test.tsx — Added a CDN mock and updated prefetch assertions to expect CDN-versioned URLs. Added a dedicated "CDN URL rewriting" test scenario.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@binayyub4211 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER
Copy link
Copy Markdown
Contributor

Kindly resolve conflict and fix workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement asset serving with CDN and caching headers

2 participants