Skip to content

Cloudflare for websites: caching, filtering, and edge configuration

Cloudflare can provide services between visitors and a website's origin server. Depending on the configuration, that can include DNS, proxying, caching, traffic filtering, and code running at the edge.

It is worth understanding which of those services a project actually uses. Pointing DNS at Cloudflare is not the same as proxying every request, and enabling one product does not automatically configure every protection.

How the proxy fits into a request

For proxied traffic, a request reaches Cloudflare before the origin. Rules and available features can determine whether the request is served from cache, forwarded, challenged, or blocked.

  • Filtering: selected traffic can be handled before reaching the application.
  • Caching: eligible content can be served without retrieving it from the origin each time.
  • Edge processing: configured logic can inspect or modify parts of the request and response.

The behavior depends on the product, plan, and settings. Review the requirements instead of assuming every feature is included in every account.

Why use it?

Traffic and denial-of-service protection

A network layer can help absorb or filter unwanted traffic before it consumes application resources. That is useful for small sites as well as larger services.

It does not establish 100% availability. The origin, configuration, application, and external dependencies can still fail. Protection should be part of an operating plan rather than a replacement for monitoring and recovery procedures.

Caching and delivery

Serving cacheable assets closer to a visitor can reduce repeated origin work and improve delivery. The benefit depends on the content, cache rules, audience, and current bottleneck.

Do not cache personalized or sensitive responses as though they were public assets. Check cookies, authorization, cache keys, and invalidation. Measure the result rather than assume a fixed percentage of bandwidth savings.

WAF and bot controls

Firewall rules and bot-related features can address selected request patterns. Review what they match and whether they interfere with legitimate visitors, search crawlers, or API clients.

These controls do not make the application immune to injection or other vulnerabilities. Application validation, authorization, updates, and secure implementation remain necessary.

An example: response headers in a Worker

A Worker can modify response headers. The original article used this illustrative example:

// Cloudflare Worker adding response headers
export default {
  async fetch(request) {
    const response = await fetch(request);
    
    // Create a response with editable headers
    const newHeaders = new Headers(response.headers);
    
    // Set policies appropriate to the application
    newHeaders.set("X-Content-Type-Options", "nosniff");
    newHeaders.set("X-Frame-Options", "DENY");
    newHeaders.set("Content-Security-Policy", "default-src 'self'");

    return new Response(response.body, {
      status: response.status,
      statusText: response.statusText,
      headers: newHeaders,
    });
  },
};

Notice the fetch(request) call: the Worker still fetches the response. Adding headers here does not mean the origin never receives a request or that meaningful CPU savings automatically follow.

The example policies are deliberately restrictive. X-Frame-Options: DENY prevents framing, and the sample Content Security Policy may block scripts, styles, or external resources the application needs. Design and test policies against the actual site before enforcing them.

Hosting and delivery workflows

Cloudflare also provides products for deploying websites and application components. Repository integration and preview environments can support a delivery workflow where they fit the selected product and framework.

Check current runtime support, build requirements, limits, and costs. A static website and a server-rendered application may require different deployment approaches. There is no universal “best hosting” choice or unlimited capacity promise.

Does it fit a small project?

It can, particularly when the required features address a real performance or traffic problem. Compare the available plan with the site's needs and the work required to configure it correctly.

For an existing site, start by reviewing DNS, proxy status, TLS, caching, and the origin's accessibility. Then test important journeys and monitor the result. A useful setup is one the team understands and can maintain, not simply a list of enabled switches.

This article was created with AI assistance. The image was also generated with AI.

Feel free to reach out

We are here for you

Your message will be read personally by me or someone from the team and we'll get back to you to talk through the details. No sales reps, straight to a practical technical consultation that moves you forward.

Personal approach
Discuss your ideas directly with the person working on your website.
Quick reply
We get back to you with clear next steps.
Looking forward to your message, Karel Sikyr, founder
Discuss your project

Contact Us