CDN for Laravel

Serve Laravel public assets and versioned Vite output from Cloud CDN. Keep session cookies, signed-in routes and form submissions with Laravel.

Example cache policy
Public, cacheable resource
/build/assets/app.15bd.js
Bypass shared cache
POST /login

Offload public files and Vite builds

Point asset and storage URLs at Cloud CDN. Cache anonymous GET pages. Bypass session, CSRF POST and Horizon/admin routes.

Vite and Mix assets at the edge

Files under public/build can retain long cache lifetimes when the build includes a content hash in each filename.

Serve public/storage outside PHP

User uploads and public disks are cached and can be transformed at delivery time.

Session Blade stays on Laravel

Authenticated dashboards and CSRF-backed forms are not cached.

Configuration

Cloud CDN overview
  1. Set ASSET_URL to Cloud CDN

    Serve hashed Vite/Mix files from the distribution after origin pull works.

  2. Cache public storage

    Map the public disk hostname to Cloud CDN.

  3. Optionally cache marketing HTML

    Anonymous landing pages can be cached with purge on deploy.

  4. Bypass the rest

    Keep login, dashboard, queues and POSTs on Laravel.

Operational outcomes

  • Laravel assets are delivered globally
  • Public storage is cached at the edge
  • Session pages remain dynamic
  • PHP workers spend less time on static files

Frequently asked questions

Does this work with Laravel Vapor or Forge?

Yes. Cloud CDN sits in front of whichever origin those platforms expose.

Can I cache full Blade pages?

Only anonymous pages without CSRF-sensitive forms or session HTML. Most app pages should bypass cache.

How should I purge after a Vite build?

Hashed files do not need purge. Purge mix-manifest/unhashed HTML if you cache it.

Can I use signed storage URLs?

Private files should stay signed at origin. Cache only public disks.