https://github.com/ilikedata/cloudflare-workers-kv-cache
Cloudflare workers KV cache
https://github.com/ilikedata/cloudflare-workers-kv-cache
cloudflare cloudflare-worker cloudflare-workers cloudflare-workers-kv javascript
Last synced: 3 months ago
JSON representation
Cloudflare workers KV cache
- Host: GitHub
- URL: https://github.com/ilikedata/cloudflare-workers-kv-cache
- Owner: ilikedata
- Created: 2020-04-29T09:35:36.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-29T09:59:26.000Z (almost 5 years ago)
- Last Synced: 2025-01-11T22:41:38.726Z (3 months ago)
- Topics: cloudflare, cloudflare-worker, cloudflare-workers, cloudflare-workers-kv, javascript
- Language: JavaScript
- Size: 19.5 KB
- Stars: 24
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cloudflare Workers KV Cache
Use Cloudflare workers and KV to reduce trips back to origin.
This was developed as a simple caching mechanism for a website with more than 50,000 images of varying sizes, total size is approximately 20gb. Despite caching in the CDN there were still many requests which come through to origin due to not being cached in all edge locations.
The chart below shows bandwidth used before & after deploying this worker.

## Installation
- Setup a KV database: `IMAGE_CACHE`
- Add an environment variable `ORIGIN_URL` which points to your origin server, path will be appended to it eg. https://images.example.com/image/file.jpg will be mapped to ORIGIN_URL/image/file.jpg
- Deploy: I installed via the web interface though deploying using wrangler is also simple.