Cache Everything Test Details

1. Test Purpose

This test demonstrates how the Cloudflare Cache Everything rule works.

Cloudflare normally does not cache HTML. With this rule, all content is cached at the Cloudflare Edge. This test lets you verify whether HTML, CSS, JS, and JPG files are cached and what their TTLs are.


Use Cases: High-traffic and mostly static pages (campaign landing pages, static images).


Benefits: Reduces origin load and improves page load speed.


Risks: If dynamic content is cached by mistake, security issues may arise.


2. Origin (Nginx) Settings

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

3. Cloudflare Settings

The Cloudflare Cache Everything rule is applied for this test.


Edge Cache TTL is set to 60 seconds.

4. Expected Behavior & Testing Methods

First request fetches from origin because content is not present in Cloudflare Edge Cache → cf-cache-status: MISS. To observe MISS perform a Purge first. If same command runs again before TTL expires → cf-cache-status: HIT.

After TTL expiration Cloudflare revalidates with origin:

  • If unchanged → cf-cache-status: REVALIDATED.
  • If changed → cf-cache-status: EXPIRED.
curl -svo /dev/null 'https://cdn.cloudflares.online/cdn/static/static_test.html' 2>&1 | grep -i 'cf-cache-status:'
curl.exe -s -D - "https://cdn.cloudflares.online/cdn/static/static_test.html" -o NUL | Select-String -Pattern '^CF-Cache-Status:' -CaseSensitive:$false

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

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

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

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

cf-cache-status Explanations

MISS → Content fetched from origin.
HIT → Content served from Cloudflare cache.
EXPIRED → TTL expired; validated with origin and if changed served from origin.
REVALIDATED → TTL expired; validated with origin and if unchanged served from cache.

5. Cloudflare Cache Rules

Cloudflare Cache Rules manage how and for how long content is cached. Short descriptions:

  • When incoming requests match… Determines which requests match the cache rule (URI, cookie, header).
  • Edge TTL Specifies how long content is stored at Cloudflare Edge. Default option uses origin header if present.
  • Browser TTL Specifies how long content is stored in the browser. Default is "Respect origin".
  • Cache key Defines elements used to build cache key (URL, cookie, header).
  • Caching on port Controls caching behavior for different ports.
  • Proxy Read Timeout How long Edge waits for origin response.
  • Serve stale content while revalidating Serve stale content while revalidation occurs.
  • Respect strong ETags Use strong ETags to validate content.
  • Origin error page pass-through Allow origin error pages to pass through.
  • Origin Cache Control Respect origin Cache-Control header when enabled (Enterprise).

This is a static page for CDN testing.

Static Image

Static JSON Fetch (Cacheable)

Loading...

Demo Video

Watch this short demo to observe CDN in action.