Question 5

Subject: Content not Being Cached

Customer Query: After activating Cloudflare on my site, I am seeing that resources on my pages are not being cached...

curl -svo /dev/null roskolniv.us
* Rebuilt URL to: roskolniv.us/
* Trying 104.16.27.128...
* Connected to roskolniv.us (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.40.0
> Host: roskolniv.us
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 22 Jun 2015 03:03:59 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0
< Strict-Transport-Security: max-age=10
< X-Powered-By: Express
< Server: cloudflare-nginx
< CF-RAY: 1fa4b922fef517a4-SIN
<
{ [3507 bytes data]
* Connection #0 to host roskolniv.us left intact
                    

Why is Cloudflare's caching not working on my site?

Response

Hi there,

Thanks for sharing the curl output — it's super helpful, and I can see exactly why your content isn't being cached.

The culprit is your origin server's cache-control headers. Specifically, it's sending this:
"Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0"

These headers are telling both Cloudflare and browsers not to cache the content at all. Since Cloudflare respects origin cache headers by default, we're following those instructions and skipping the cache.

Here's how you can fix this:

You've got a few options depending on how much control you want:

  1. Update Cache Headers at the Origin
    Modify your server to send more cache-friendly headers, like:
    Cache-Control: public, max-age=3600
    This tells Cloudflare (and browsers) to cache the response for one hour.
  2. Use Cloudflare Cache Rules
    Override your origin headers directly in the Cloudflare dashboard with Cache Rules. This gives you fine-grained control over what gets cached and when.
  3. Set Up a Page Rule
    If you prefer a simpler approach, create a Page Rule and set the Cache Level to "Cache Everything". This ignores the origin headers entirely and forces caching.

For a deeper dive into how caching works with Cloudflare and the different options available, check out:
🔗 Cloudflare Cache Behavior Explained

Let me know which option feels right for you, and I'd be happy to walk you through the setup.

Best regards,
Aviv
Cloudflare Support

Thought Process

This question involves a technical analysis of HTTP headers to diagnose a caching issue. The curl output provided by the customer contains all the information needed to identify the problem.

Tools I would use to investigate this issue:

  • HTTP header analysis: Examining the Cache-Control headers
  • Cloudflare Cache documentation: Understanding default cache behaviors
  • curl: For testing cache implementation changes
  • Cloudflare Dashboard: To set up and monitor cache rules

My approach is to first explain the cause of the issue clearly, then provide multiple solutions that vary in complexity and implementation method. This gives the customer options based on their technical comfort level and specific needs.

Back to Questions