Engineering Clean HTTP 404 Responses for APIs, SPAs, and Search Crawlers
HTTP 404 Not Found communicates that no resource exists at the requested URI without promising whether the absence is temporary or permanent. In REST APIs, always return a genuine 404 status line with a structured problem+json payload rather than returning 200 OK with {"found": false}. Returning 200 on missing web pages creates a "soft 404" that wastes crawl budget and confuses CDN analytics.
Because 404 is heuristically cacheable under RFC 9110, CDNs like Cloudflare and Fastly can cache 404 responses for several minutes unless you specify Cache-Control. That is great for absorbing bot scans against missing static assets, but dangerous on write-then-read APIs where a record might be created seconds after a lookup—use Cache-Control: no-store on dynamic API 404 responses.
Default CacheabilityHeuristically cacheable by default per RFC 9110 §15.1
SEO GuidancePrefer 404 for unknown paths, 301 for moved paths, 410 for intentionally purged paths
What is the difference between HTTP 404 Not Found and 410 Gone?
404 means the resource is currently not found without stating if it ever existed. 410 Gone explicitly tells clients and search engines the resource existed previously and was permanently removed.
Why does refreshing a React or Vue route return 404 on Nginx?
Client-side routers handle virtual paths in JavaScript. Configure Nginx with try_files $uri $uri/ /index.html; for SPA routes, while keeping real missing API/asset routes returning true 404s.
Are HTTP 404 responses cached by CDNs?
Yes, 404 is cacheable by default under RFC 9110. Set Cache-Control: no-store on dynamic endpoints if newly created records must be visible immediately.