Closed gijo-varghese closed 1 year ago
I've noticed the same thing on the KeyCDN tools performance tester. "Cache Everything" page rule gives me insanely fast TTFB times on that test, but the workers cache setup does not. Inspecting the headers whos me there are no edge-cache headers coming from CF on the requests.
However, if I VPN into different countries and test the site with the workers setup, the proper edge-cache headers are present and the TTFB is great.
With that, I assume the KeyCDN test is bypassing the workers script somehow, but real world tests show it works.
@michaelbourne yeah, I noticed it too. Headers are not shown. But there is no way fo KeyCDN to detect whether it's coming from the worker or not right? @pmeenan any thoughts on this?
@gijo-varghese — can you provide the Worker code you’re using?
@shagamemnon it's mostly the same as in https://github.com/cloudflare/worker-examples/blob/master/examples/edge-cache-html/edge-cache-html.js
But I've disabled the lines from https://github.com/cloudflare/worker-examples/blob/8affa71e494e43a2d2c2c106a9ad03f84472cc42/examples/edge-cache-html/edge-cache-html.js#L171 because KeyCDN and similar tools send a 'no-cache' headers
@shagamemnon any updates?
@michaelbourne how much TTFB are you getting? When I tested it with GTmetrix, it's still around 200-300ms, with cache hit
My best was around 115ms, worst 300ms. I've never seen it under 100ms with CloudFlare, in any setup. ~100ms is a fair trade off to me for the additional benefits they offload from my server though.
yes, <100ms is more than enough. Even the cache everything rule gives <60ms in most of the locations (https://tools.keycdn.com/performance?url=https://coffeencoding.com/). Don't know what's wrong with service workers
@gijo-varghese Still seeing the same TTFB or have you switched on ARGO for lower TTFB?
@alriksson I've turned off Cloudflare for now
@gijo-varghese I see, may I ask Why? or just temporary dev mode?
@alriksson CF is lowering my TTFB. It's better to directly connect to the server
Okay, but it should be faster to connect to your server through CF with ARGO or when HTML is cached in the edge?
@alriksson Argo costs money, and I'm not willing to pay that for now. Also, there are a lot of troubles occurring when I cache HTML
I see, haven't experienced that much of troubles with cache HTML but do not have any memberships or transactional website so.
Thanks for sharing :)
@alriksson I've explained a few issues with WP here: https://wpspeedmatters.com/caching-html-pages-at-the-edge-using-cloudflare/
@gijo-varghese Yes correct! :)
But I understand it can cause issues depending on the need and sites, but then ARGO is an alternative for the one who want to pay. But the calculation of use is a bit off to pay all traffic not only the one fetched from the origin.
Did you use the free workers or the KV? Since KV do not flush the whole instance as long as you don't manually trigger the purge. KV is of course paid which wasn't what you were looking for.
I haven't tried ARGO myself to see the reduce in TTFB 35% is what they marketing it as.
This repo has been moved over to the workers-sdk monorepo located here: https://github.com/cloudflare/workers-sdk/tree/main/templates
If you still have further issues about this, feel free to create an issue there. I will be closing this out for now.
I've implemented as per the docs in the demo site https://gijovarghese.com. However, there is no much difference in TTFB
On testing, most of the locations have a TTFB of greater than 500ms. I tested it via https://tools.keycdn.com/performance?url=https://gijovarghese.com/. I tested multiple times so that it would cache in all servers
However, TTFB of another WP site which implemented page rules to cache everything have a TTFB <100ms in all around the world. See https://tools.keycdn.com/performance?url=https://coffeencoding.com/
What could be the reason?
Note: I've removed the part that checks for 'no-cache' header since most these tools send no-cache header