I have total complete lost my mind over how to get cloudflare to cache a simple css file. I have been working with htaccess to set expiration headers, but cloudflare does not seem to respect them.
I have a site where the origin returns the following headers for a CSS file:
Cache-Control: public, max-age=2592000,s-maxage=14400 Expires: Sun, 26 May 2019 07:29:49 GMT Content-Type: text/css Content-Length: 3195 Date: Fri, 26 Apr 2019 07:29:49 GMT Server: LiteSpeed Access-Control-Allow-Origin: * Alt-Svc: quic=":443"; ma=2592000; v="35,39,43,44" Connection: Keep-Alive
Caching Level set to standard and
Browser Cache Expiration set to respect existing headers I would expect the following:
The file would be edge cached for 14400 seconds, and browser cached for 1 month.
However the Cloudflare response I get is:
Date: Fri, 26 Apr 2019 07:30:25 GMT Content-Type: text/css Transfer-Encoding: chunked Connection: keep-alive Cache-Control: no-cache Expires: Fri, 26 Apr 2019 07:30:23 GMT Vary: Accept-Encoding Access-Control-Allow-Origin: * X-Turbo-Charged-By: LiteSpeed CF-Cache-Status: MISS Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" Server: cloudflare CF-RAY: 4cd6d9e7fd17bdac-AMS
If I turn on a page rule with Origin Cache Control: On nothing changes from the above. However if I make the page rule explicitly with an Edge Cache TTL (any value) I get the following response:
Date: Fri, 26 Apr 2019 07:39:31 GMT Content-Type: text/css Content-Length: 3183 Connection: keep-alive Access-Control-Allow-Origin: * Cache-Control: no-cache Cf-Bgj: minify Cf-Polished: origSize=3195 Expires: Fri, 26 Apr 2019 07:39:26 GMT X-Turbo-Charged-By: LiteSpeed CF-Cache-Status: HIT Accept-Ranges: bytes Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" Server: cloudflare CF-RAY: 4cd6e7426c38c835-AMS
Again by adding a Browser Cache TTL (any value) I can get a cache-control header (the rest is the same as above even the expires header that is in the past)
Date: Fri, 26 Apr 2019 07:41:14 GMT Cache-Control: private, max-age=345600 Expires: Fri, 26 Apr 2019 07:39:26 GMT CF-Cache-Status: HIT