Bypass Cache for Everything Test Details

1. Test Purpose

This test demonstrates how the Bypass Cache for Everything rule in Cloudflare works, serving content directly from the origin without caching.


Normally, Cloudflare caches some content at the Edge. With this rule, HTML, CSS, JS, and other files are served directly from the origin without being cached.


Use Cases: Pages with frequently changing dynamic content or pages that must always show up-to-date information.


Benefits: Content is always up-to-date.


Risks: Increased load on the origin server and potentially longer page load times compared to Cache Everything.


2. Origin (Nginx) Settings

# ---- Bypass Cache for Everything ----
location /cdn/dynamic/ {
    alias /var/www/cloudflare/application-service/cdn/dynamic/;
    index dynamic_test.html;
    try_files $uri $uri/ =404;
}

3. Cloudflare Settings

The Bypass Cache for Everything rule is applied in Cloudflare.


All content is fetched directly from the origin without being cached at the Cloudflare Edge. Edge Cache TTL has no effect in this mode; however, the Browser TTL can be set in the Cloudflare dashboard to control cache directives sent to browsers — content is still not stored at the Edge.


4. Expected Behavior & Testing Methods

Requests are always fetched from the origin. However, cf-cache-status may not always show BYPASS.

  • Dynamic content (e.g., HTML): DYNAMIC
  • Static files (JPG, CSS, JS, etc.): DYNAMIC
  • Special cases (Cache-Control: no-store, cookie match, etc.): BYPASS

Despite these differences, no content is written to the cache, and every request is served directly from the origin. The bypass rule works correctly.


curl -svo /dev/null 'https://cdn.cloudflares.online/cdn/dynamic/dynamic_test.html' 2>&1 | grep -i 'cf-cache-status:'
curl.exe -s -D - "https://cdn.cloudflares.online/cdn/dynamic/dynamic_test.html" -o NUL | Select-String -Pattern '^CF-Cache-Status:' -CaseSensitive:$false

curl -svo /dev/null 'https://cdn.cloudflares.online/cdn/dynamic/dynamic_test.css' 2>&1 | grep -i 'cf-cache-status:'
curl.exe -s -D - "https://cdn.cloudflares.online/cdn/dynamic/dynamic_test.css" -o NUL | Select-String -Pattern '^CF-Cache-Status:' -CaseSensitive:$false

curl -svo /dev/null 'https://cdn.cloudflares.online/cdn/dynamic/dynamic_test.js' 2>&1 | grep -i 'cf-cache-status:'
curl.exe -s -D - "https://cdn.cloudflares.online/cdn/dynamic/dynamic_test.js" -o NUL | Select-String -Pattern '^CF-Cache-Status:' -CaseSensitive:$false

curl -svo /dev/null 'https://cdn.cloudflares.online/cdn/dynamic/dynamic_api_response.json' 2>&1 | grep -i 'cf-cache-status:'
curl.exe -s -D - "https://cdn.cloudflares.online/cdn/dynamic/dynamic_api_response.json" -o NUL | Select-String -Pattern '^CF-Cache-Status:' -CaseSensitive:$false

curl -svo /dev/null 'https://cdn.cloudflares.online/cdn/dynamic/image.png' 2>&1 | grep -i 'cf-cache-status:'
curl.exe -s -D - "https://cdn.cloudflares.online/cdn/dynamic/image.png" -o NUL | Select-String -Pattern '^CF-Cache-Status:' -CaseSensitive:$false

cf-cache-status Explanations

BYPASS → Content not cached, request served directly from origin (seen in special cases).
DYNAMIC → Dynamic content, never cached by Cloudflare.
MISS → Static content not present in cache, fetched from origin (not written to cache in this mode).

5. Cloudflare Cache Rules

In Bypass Cache for Everything, Cloudflare Cache Rules ensure content is served without caching. Important settings:

  • When incoming requests match… Determines which requests match the cache rule (URI, cookie, header).
  • Browser TTL Duration content is stored in user browsers. "Respect origin" is default.

This is a dynamic page for CDN testing.

Dynamic Image

Dynamic JSON Fetch (Origin)

Loading...

Demo Video

Watch this short demo to observe CDN in action.