Q27: How does HTTP Caching differ between REST and GraphQL?
REST leverages native HTTP caching primitives (like Cache-Control, ETag, 304 status codes) via resource URIs and GET requests.
GraphQL uses POST requests to a single /graphql URL, rendering standard HTTP URL caching ineffective. Instead, GraphQL caching relies on:
- Client-side Normalized Caching (by
__typename+idinside Apollo/Relay). - Persisted Queries / Automated Persisted Queries (APQ) to allow HTTP GET caching.
Key Takeaways
- GraphQL POST operations bypass default CDN/HTTP path caching.
- Client caches normalize graphs into key-value stores using unique object IDs.
Knowledge Check
What primary feature prevents standard HTTP CDNs from caching default GraphQL queries?