Original Authority
Original Authority
CDCloudflare Developers
Created by Original Authority on 9/24/2023 in #workers-help
Worker doesn't seem to be caching
I just want to get a bit of advice on caching, and what I'm experiencing. I'm using this code https://pastebin.com/0kDUVewt to cache my website, and adding a query parameter to differentiate between mobile and desktop. It seems to be working, but there seems to be some cache fragmentation or something. Basically, when I visit my site, it shows a hit, but the 'age' seems to be a very low number. I.e, if I visit, and then revisit in about 5 minutes, the 'age' is back at 0, which I believe is telling me that the cached version I'm seeing is new, and not the same version from the cache that I was seeing 5 minutes ago. Does anyone have any ideas, or tips on how to solve this? Sometimes if I refresh, I'm seeing the age of the cache'd version back at 0?
3 replies
CDCloudflare Developers
Created by Original Authority on 9/17/2023 in #workers-help
Caching different version mobile/desktop
I've finally gotten Cloudflare to cache my website using service workers (I'll switch to ES format in the future when it's up and running), and it caches properly. My website has a different theme for mobile and desktop viewers (completely different). When my site detects a mobile UA, it sends a cookie, which tells my website to use the mobile theme. When I view pages that are cached, however, Cloudflare shows the web version instead of caching and showing a mobile version; the cookie is still sent. I know enterprise users can do this with cache keys, but is there any way to force CF to cache and deliver a different version by mobile/deskop? Perhaps by detecting the cookie or otherwise?
1 replies
CDCloudflare Developers
Created by Original Authority on 9/6/2023 in #workers-help
How to deploy worker?
I'm probably being a bit stupid here, but I'm really new to Workers, having been using page rules before (looking for a bit more flexibility on cookie bypass etc, and don't want to shell out for enterprise/business). I have a Worker script (pastebin for anyone interested: https://pastebin.com/5kUGaL2S) that I think does what I need (bypass on certain cookies etc), and I've tried to set it up, but I'm having a bit of difficulty getting it to actually work. Basically, I have a domain (domain.com, redacted in the script) and several subdomains (.domain.com, wildcard), and I need the worker to be the one to intercept the request and then pass it to the server if it can't be served from the cache. I've done the following: - saved and deployed - added a route for domain.com with the zone domain.com - added a route for *.domain.com with the zone domain.com, but it doesn't seem to be actually working (I can tell because my worker should be logging the start time to the console), am I being really stupid, or? Does anyone know what I'm doing wrong? Oddly enough, I can see 1.2k requests when I look at the worker?
9 replies