Cloudflare

5. Content not Being Cached

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?


Dear User,

Thank you for reaching out about your questions related to issue with caching.

Based on the curl output you've provided, it appears that Cloudflare's caching is not working on your site due to the Cache-Control header being set to prevent caching:

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0

This header is instructing browsers and intermediary caches (including Cloudflare) not to cache the content. Cloudflare respects the origin's cache headers by default. When it sees these no-cache directives, it won't cache the content.

To fix this issue and enable Cloudflare caching, you need to:

1. Modify your origin server (Express app) to set appropriate caching headers for content you want to be cached.
2. Configure Cloudflare to override or ignore the origin's cache headers if needed: https://developers.cloudflare.com/cache/how-to/edge-browser-cache-ttl/

If you have followed these changes and the issue persists, please provide any logs or response headers with URL examples and I will be happy to assist you further.

Best regards,
Szymon Kamiński
Cloudflare Support