The Website Previewer

Blog

How We Built the hosts.click Server Diff Tool

May 8, 2026
Diagram: the same hostname is requested from the current server IP and the new server IP, with the same Host header. The responses are compared before DNS changes.

The DNS cutover diff tool at hostsclick.com/server-diff compares two servers serving the same hostname before you flip DNS. This post walks through the engineering decisions behind it.

Test the new server before you change DNS. Open the free preview tool

The Host-header trick

The whole tool rests on one cURL option: CURLOPT_RESOLVE. Given a hostname, port, and IP, cURL bypasses DNS resolution and connects directly to the IP — but the TLS handshake and HTTP request still send the original hostname via SNI and the Host header. The target server thinks it's serving the real domain, complete with whatever vhost config and SSL cert apply.

This is the same mechanism the preview-link tool uses to render a domain's content from any IP. For server diff, we just point cURL at two different IPs in parallel and capture both responses.

Parallel fetches with curl_multi

For 5 paths × 2 servers = 10 simultaneous requests. Sequential cURL would take 10× the slowest path's response time. curl_multi_init + curl_multi_exec handles all 10 in parallel, bounded by the slowest single request (typically 2-8 seconds against a healthy server). Each handle has its own header callback that captures only the 16 headers we care about (Cache-Control, CSP, Set-Cookie names, etc.) — Date, Server timing, X-Cloudflare-* and other variable noise gets dropped.

Why synchronous, not async

Most "scan multiple URLs and produce a report" tools queue the job and poll for completion. We chose to run the scan inside the HTTP request and block until done. The reason: scan duration is bounded by parallel cURL to roughly the slowest single path. Free tier (5 paths) finishes in 3-5 seconds; Pro API (50 paths) in 10-30. Both fit inside a 60-second PHP-FPM request budget.

Adding async would mean a queue daemon, a database table for pending jobs, polling UI on the frontend, retry logic for partial failures, and result TTL cleanup. None of that earns its complexity at our scale yet. github.com/shukiv tracks the implementation if you want to dig in.

What we ignore in the diff

The naive approach to header diffing — "compare every header value, flag mismatches" — is unusable in practice. Set-Cookie is the obvious one: every request gets fresh CSRF and session tokens, so values always differ. We compare cookie names only, not values. Date is dropped entirely. Server timing headers like X-Response-Time are dropped. Response time itself is only flagged when the delta exceeds 200ms, since small variation is expected.

Body content hashing avoids the same problem. We SHA-256 the entire body and compare hashes. Identical hashes = identical bodies. Different hashes = something changed (database not migrated, theme broken, asset paths wrong), or the page holds a value that changes on every request, such as a CSRF token in a form. The hash is taken over the raw body with no normalization, so such a page can differ even when its content is the same. For those pages, compare status, headers and visible content as well. No noisy line-by-line diff to wade through.

Mixed-content detection

One regression operators care about during HTTPS migrations: an HTTPS page that loads an HTTP asset. Browsers block these or downgrade trust. We parse each fetched HTML body for three patterns: src="http://" attributes, <link>/<script> tags with href="http://", and inline url(http://...) in styles. The count is reported per server. If old has 0 and new has 12, you have a regression to fix before flipping DNS.

Free tier vs Pro API

The free web form caps at 5 paths and 1 scan per 10 minutes per IP. The Pro API at POST /api/server-diff takes up to 50 paths and 30 scans per hour per API key. Same Scanner service backs both; the controllers just enforce different limits. The Pro tier is intended for CI hooks: run the diff after every staging deploy, fail the pipeline if regressions appear.

What's next

The sync architecture has a clear ceiling. When p95 scan time hits 30 seconds or concurrent scans regularly exceed 5/min, we'll move to async + queue. ADR-0005 in the repo documents the threshold. Pro features in the backlog: scheduled recurring scans (cron-based), Slack/email alerts on regression, PDF export for client signoff, 90-day result history.

The tool is live at /server-diff — try it on your next migration.

Related Guides

Improve Preview Workflows

Use these focused guides for DNS previews and control panel integrations.

Toggle navigation