Static loading slow for European users? Origin server struggling under peak loads, TTFB climbing above 300 ms, and Core Web Vitals failing audits. For projects on Laravel, WordPress, or custom PHP, a typical issue is latency from remote infrastructure. We help set up KeyCDN—a European CDN with 35+ points of presence (PoPs), low latency, and pay-as-you-go pricing. After integration, TTFB drops to 30–50 ms, server load decreases by 85%, and cache hit rate reaches 98% with proper headers.
KeyCDN uses HTTP/2 and supports on-the-fly WebP conversion. We've connected it for 50+ sites—results are stable. Below we break down typical problems and the setup process.
Problems We Solve
- High TTFB—requests travel thousands of kilometers. KeyCDN brings content closer to users (PoPs in Frankfurt, Amsterdam, London), reducing latency by 3–5x.
- Origin overload—static files (CSS, JS, images) are served from the CDN, reducing server load by up to 80%.
-
No WebP support—KeyCDN converts images to WebP on the fly, without changing URLs (via the
format=webpparameter). -
Suboptimal caching—we set
Cache-ControlandExpiresheaders to maximize browser and CDN caching.
Pull Zone: How It Works
We use Pull Zones—KeyCDN fetches content from the origin on the first request. No rsync or FTP needed. For projects with already-uploaded files, Push Zones are suitable, but Pull is standard for dynamic sites.
Example of creating a Pull Zone via API:
curl -X POST \ -u api_key: \ -H "Content-Type: application/json" \ -d '{ "name": "example-assets", "type": "pull", "origins": [{"url": "https://example.ru"}], "ssl": true, "cors_headers": true, "cache_headers": true, "expire": 2592000, "custom_domains": ["cdn.example.ru"] }' \ https://api.keycdn.com/zones.json After creation, KeyCDN provides a CNAME (e.g., example-assets-1234.kxcdn.com). We add a CNAME record in DNS. SSL for the custom domain is issued automatically via Let's Encrypt.
| Criteria | Pull Zone | Push Zone |
|---|---|---|
| Source | Origin server (HTTP) | Direct upload (rsync/FTP/API) |
| Update | Automatic after invalidation | Requires manual upload |
| Traffic | Inbound + outbound | Outbound only (cheaper) |
| Use case | Dynamic sites | Static files, archives |
For 90% of projects, we choose Pull—minimal manual work.
How to Set Up HTTPS for a Custom Domain?
After adding a custom domain to the zone, KeyCDN automatically issues a certificate via Let's Encrypt. Just point a CNAME to the provided CDN domain and wait 1–5 minutes. No manual CRL or CSR. Important: for HTTPS, make sure your origin server also serves static files over HTTPS to avoid mixed content.
Why Cache Invalidation Is Critical
Without it, after updating files (e.g., app.css?v2), users see the old version. Invalidation clears specific URLs or the entire zone. We implement it via API: call DELETE /zones/purgeurl/{zoneId}.json with a URL array. In Laravel, this is wrapped in a service provider (see below). Cache hit rate drops to 0% without invalidation—critical for updates.
Integration with Laravel
Simple static asset redirection via a service provider:
// config/cdn.php return [ 'url' => env('CDN_URL', ''), 'enabled' => env('CDN_ENABLED', false), ]; // AppServiceProvider: override URL for assets public function boot(): void { if (config('cdn.enabled') && $cdnUrl = config('cdn.url')) { URL::forceRootUrl($cdnUrl); } } In templates, just use asset():
{{-- In templates -- }} <img src="{{ asset('images/logo.png') }}" alt="KeyCDN setup"> {{-- Outputs: https://cdn.example.ru/images/logo.png -- }} Cache invalidation—wrapper via API:
use Illuminate\Support\Facades\Http; class KeyCdnService { private string $apiKey; private string $zoneId; public function purge(array $urls): void { Http::withBasicAuth($this->apiKey, '') ->delete("https://api.keycdn.com/zones/purgeurl/{$this->zoneId}.json", [ 'urls' => $urls, ]); } public function purgeAll(): void { Http::withBasicAuth($this->apiKey, '') ->get("https://api.keycdn.com/zones/purge/{$this->zoneId}.json"); } } Origin Header Configuration
KeyCDN caches what the origin sends. Proper headers on Nginx:
location /assets/ { expires 1y; add_header Cache-Control "public, max-age=31536000, immutable"; add_header Access-Control-Allow-Origin *; } | Header | Recommended value | Purpose |
|---|---|---|
Cache-Control | public, max-age=31536000, immutable | Long-term caching for immutable files |
Expires | 1y | Expires after a year |
Vary | Accept-Encoding | Support compression |
To improve hit rate, use s-maxage and stale-while-revalidate for the CDN. Enable WebP via the ?format=webp parameter in zone settings.
Our Process
- Audit—analyze current metrics, identify static resources, check caching headers.
- Zone creation—set up Pull Zone, specify origin, enable HTTPS, CORS, custom domain.
- DNS—add CNAME record, wait for propagation (up to 30 minutes).
- SSL—KeyCDN automatically issues Let's Encrypt.
- Integration—plug CDN into code (Laravel, WordPress, any CMS), set up cache invalidation.
- Testing—verify caching accuracy, load speed, WebP.
- Monitoring—set up KeyCDN analytics (traffic, cache hit rate, status codes).
What's included: integration documentation (code, commits), access to KeyCDN panel, API keys, team training on cache and invalidation, 30-day technical support.
Timelines and Guarantees
Basic setup—2 to 4 hours from access provision. Complex projects (custom origins, multiple zones)—up to 2 days. Pricing is individualized. 5+ years of experience, 50+ projects delivered—we guarantee stable operation and support. Contact us for a free audit of your current infrastructure. Get a consultation on KeyCDN setup.







