Cloudflare Worker Geo-Cache Service
Budget: $30 – $250 USD
I need a lightweight, stateless Cloudflare Worker that takes in a pair of Latitude/Longitude coordinates, checks a daily edge-cache entry keyed to that location, and immediately returns the cached object when it exists. If the key is missing or expired, the Worker must call a Weather API, run my proprietary custom algorithm on the response, store the processed result back in the edge cache with a 24-hour TTL, and finally send the processed payload to the requester.
Core flow
1. Parse incoming lat/lon from the request path or query string (I’m flexible here; just keep the interface simple).
2. Look up the coordinate-based key in Cloudflare KV or R2 (whichever meets best-practice latency inside Workers).
3. When absent, fetch fresh data from the Weather API endpoint I will provide, apply my closed-source algorithm (I’ll drop the code or WebAssembly module into the repo), then cache the output.
4. Return JSON containing both the processed data and a field that indicates cache-hit vs cache-miss.
Deliverables
• TypeScript source for the Worker, ready to deploy with Wrangler 3.x.
• A short README covering config, env vars (API key, cache namespace), and the curl example for testing.
• One-line Wrangler command to publish plus sample wrangler.toml.
• Basic unit test stubs showing how to mock the Weather API call.
Acceptance criteria
• <50 ms median response for a cache hit in the same region.
• Weather API calls fire only on true cache misses.
• Output format exactly matches the JSON schema I’ll supply.
• Cleanly linted code and passes wrangler test.
Core flow
1. Parse incoming lat/lon from the request path or query string (I’m flexible here; just keep the interface simple).
2. Look up the coordinate-based key in Cloudflare KV or R2 (whichever meets best-practice latency inside Workers).
3. When absent, fetch fresh data from the Weather API endpoint I will provide, apply my closed-source algorithm (I’ll drop the code or WebAssembly module into the repo), then cache the output.
4. Return JSON containing both the processed data and a field that indicates cache-hit vs cache-miss.
Deliverables
• TypeScript source for the Worker, ready to deploy with Wrangler 3.x.
• A short README covering config, env vars (API key, cache namespace), and the curl example for testing.
• One-line Wrangler command to publish plus sample wrangler.toml.
• Basic unit test stubs showing how to mock the Weather API call.
Acceptance criteria
• <50 ms median response for a cache hit in the same region.
• Weather API calls fire only on true cache misses.
• Output format exactly matches the JSON schema I’ll supply.
• Cleanly linted code and passes wrangler test.
Related categories:
Data Processing
Cloud Computing
JSON
Web Development
HTTP
Edge Computing
API Development
Cloudflare