Cloudflare at the edge of a SaaS application.
Use separate edge policies for public content, authenticated resources, and webhooks. Keep application authorization at the origin, prevent direct bypass of intended edge controls, and test cache behavior with different customer identities.
Inside this article 5 sections +
Cloudflare can protect and accelerate the edge of a SaaS application, but the architecture still needs explicit boundaries for public caching, authenticated requests, and origin access. Start by classifying routes according to the data they return and the authority they require.
A useful design separates a public documentation page, a workspace dashboard, and a webhook endpoint even when they share one hostname. Their cache policy, authentication checks, retry behavior, and failure consequences are different.
Classify request paths before writing cache rules
Public assets with content-hashed filenames are good caching candidates because their URLs change with their content. Public marketing pages may tolerate a short period of stale content. An account dashboard or export download needs a much stricter policy because its response depends on the authenticated customer and current permissions.
Make the origin return deliberate cache headers, and review any edge rule that overrides them. A broad cache rule can turn an otherwise correct application response into shared content. For sensitive authenticated responses, an explicit bypass and appropriate non-storage directives are easier to reason about than relying on incidental cookies or current platform defaults.
Keep authorization attached to the resource
Edge filtering can reject abusive traffic, enforce selected access checks, or apply rate limits. It does not replace the application's decision about whether person P12 may read workspace A50. The origin must validate the session and resource relationship even when the request has passed through a trusted edge.
Do not treat a forwarded account header as authority unless it is produced and verified through a deliberately secured mechanism. Strip or overwrite headers that clients could otherwise forge. When edge code forwards identity information, define its issuer, integrity protection, audience, and expiry just as carefully as another service credential.
For a permission-sensitive download, test access after membership revocation. A signed URL or cache entry may outlive the application permission that created it. Decide whether that lifetime is acceptable, then encode the lifetime and storage rules consistently. The permission-aware retrieval guide explores the same distinction between a retrieved object and authority to reveal it.
Close the direct path to the origin
If an attacker can reach the origin directly, they may bypass rules enforced only at the edge. Use an origin connection design appropriate to the hosting environment, such as constrained network access, a tunnel, or authenticated origin connections. Preserve an operational path for health checks and recovery without making that path a public bypass.
Cloudflare Authenticated Origin Pulls uses client certificates to authenticate connections from Cloudflare to an origin. The exact certificate scope matters: a shared provider certificate is a different assurance from a configuration tied to your own zone or hostname. Combine connection authentication with the intended hostname, TLS validation, and application checks.
Document certificate rotation and the behavior when origin authentication fails. A deployment that updates only one side can make the application unreachable. Test the rejected path directly as well as the successful route through the edge.
Treat webhooks as a separate operational lane
Webhook senders may not behave like browsers. Interactive challenges can prevent legitimate delivery, and retry patterns may produce bursts. Scope rules to preserve the expected sender path while validating signatures and timestamps in application code. A claimed source IP alone is usually insufficient evidence of a valid business event.
Persist a validated receipt before acknowledging delivery, then process the event through a durable worker. Repeated delivery should find the same receipt or business operation rather than performing the action twice. The reliable background jobs guide covers recovery after that acceptance boundary.
Track separate metrics for edge rejection, origin rejection, durable acceptance, and processing completion. A single HTTP success rate can hide a queue that accepted every webhook but stopped applying them.
Include query parameters and alternate hostnames in the test set. They can change which cache key or route rule applies. A policy validated only against the primary URL may leave another path returning the same private resource under different storage behavior.
Test cache behavior with two customer identities
Request the same private URL as account A, then as account B, then without authentication. Repeat after changing a role and after updating the underlying record. Check the response body and cache behavior at each step. A cache hit ratio does not establish that the right customer received the right data.
Run the same exercise against public routes to confirm that intentional caching still works. Keep the route policy next to deployment configuration so a new endpoint inherits a conscious choice. Architecture design can align those edge rules, origin protections, and application permissions into a request path that remains understandable during incidents.