Original Authority
Original Authority
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