Someone knows how reddit manages to bypass cloudflare static html caching once the user logs in successfully with a reload of page?
I see that the current page gets reloaded after a successful login.
Response headers before login:
CF-Cache-Status: HIT
CF-RAY: 23b76b8270950e30-MXP
Cache-Control: max-age=0, must-revalidate
Content-Encoding: gzip
Content-Length: 20794
Content-Type: text/html; charset=UTF-8
Date: Mon, 26 Oct 2015 16:08:27 GMT
Server: cloudflare-nginx
Vary: Accept-Encoding
X-Firefox-Spdy: 3.1
X-Frame-Options: SAMEORIGIN
strict-transport-security: max-age=15552000; includeSubDomains; preload
x-content-type-options: nosniff
x-moose: majestic
x-ua-compatible: IE=edge
x-xss-protection: 1; mode=block
Response headers after login:
CF-RAY: 23b76cb065140e30-MXP
Cache-Control: private, s-maxage=0, max-age=0, must-revalidate, max-age=0, must-revalidate
Content-Encoding: gzip
Content-Length: 18697
Content-Type: text/html; charset=UTF-8
Date: Mon, 26 Oct 2015 16:09:16 GMT
Expires: -1
Server: cloudflare-nginx
Vary: accept-encoding
X-Firefox-Spdy: 3.1
X-Frame-Options: SAMEORIGIN
strict-transport-security: max-age=15552000; includeSubDomains; preload
x-content-type-options: nosniff
x-moose: majestic
x-ua-compatible: IE=edge
x-xss-protection: 1; mode=block
Thanks for any hints.
There are two key ways of doing this with CloudFlare:
In order to set-up a Page Rule
Set Cache Headers
CloudFlare's Help Centre explains how to control cache through the headers sent from the origin:
In PHP you can implement this using the header function as follows: