chcs Posted October 30, 2019 Share Posted October 30, 2019 Because of some server issues, and page loading speed and performance, I've been using Cloudflare to set up "cache everything" page rules for various sites. Cloudflare, by default, only caches assets like css or jpgs, but not the actual document html that is created by the server on request. Setting "cache everything" changes that and allows Cloudflare to serve up the html directly (rules providing). This cuts down the initial TTFB (time to first byte) considerably, especially during high traffic or server attacks. In order to tell whether Cloudflare is serving up an asset or not, you need to inspect the headers (break out your html inspectors and look at the network tab). In the response for the asset (jpg, css, document, etc) you'll see an attribute for "CF-CACHE-STATUS" and the associated value. <?php // include "../index.php"; $name = $_REQUEST["name"]; echo "<pre>"; echo "hello ?name=$name"; $number = 9; while ($number > 0) { $result = $number - 1; echo " $number - 1 = $result "; $number--; } The above is the code in a file named https://www.chas.us/test/no_pw.php With your developer tools tuned to the network tab you can load this page. you can provide it different querystrings in order to trigger Cloudflare to react and cache it, while you study the cf-cache-status flag https://www.chas.us/test/no_pw.php?name=chcs CF-CACHE-STATUS = MISS reload CF-CACHE-STATUS = HIT What does this mean? It means that you made a request, through Cloudflare, to get the page. Cloudflare realized it didn't have a copy of it, so it went to the server directly for it. When the server created the html, Cloudflare served it to you and stored it. However, on your subsequent reloads, Cloudflare will realize that it has the copy and serve it directly to you, without requiring your server to execute php to recreate it. You have effectively "HIT" the cached version. I have a second file where I merely un-comment the include line that bootstraps Processwire. I did this as the most bare-bones attempt at troubleshooting what I was seeing in a conventional Processwire site/templates driven website. With your developer tools tuned to the network tab... And following the same procedure you did above https://www.chas.us/test/pw_included.php?name=ohhello CF-CACHE-STATUS = BYPASS reload CF-CACHE-STATUS = BYPASS As you can see, I am not using any Processwire methods to output code, but when I include it when generating the page... something about it causes Cloudflare to not cache the generated page. This is a problem whether I am bootstrapping PW (like the above bare-bones example) or whether I am using it in the standard conventional way for a proper website. Cloudflare seems to always get bypassed so that the server can create the the page. I've also attempted to change the template cache value to see if that would somehow enable Cloudflare to serve the page, but it does not. Not sure how to proceed, as this finding seems to indicate that I cannot leverage the speed of Cloudflare on websites that employ Processwire to generate the html markup. Help! Link to comment Share on other sites More sharing options...
jacmaes Posted May 9, 2022 Share Posted May 9, 2022 I've been playing with CloudFlare's cache everything feature to serve a site that's hardly ever updated from the edge. It works amazingly well on non-PW sites, speed is so fast it seems you're serving the site locally. But I'm having the same issue as @chcs with that PW site, all assets are fully cached but the page. You can easily check this using Dr Flare's extension on Chrome. Anyone knows why the response header is set to no-cache for HTML pages served by ProcessWire, and how we can bypass this? 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now