This repository contains a rudimentary cache suitable for APIs or similar endpoints.
It has three functions:
Get
(expectsx-api-key
header to be passed to origin; easy to remove if you don't like it)Delete
List
Since this uses Cloudflare Workers and KV, you need to have a Cloudflare account. Workers can be used in a free account, however KV cannot. For that you will need Workers Unlimited ($5/month).
I assume you have Wrangler installed.
Also make sure to rename wranglerdottoml
to wrangler.toml
and set all the empty fields to your own values. Make sure to set the "name" field to different names between the three files so they don't conflict. Then copy the files to their respective function folders.
Run wrangler dev
in the respective subfolders. This does not currently support KV functionality though!
I would recommend just logging into Cloudflare and using the "quick edit" view for any development work.
Standard way: Run wrangler publish
in the respective subfolders.
I've added a few helpers in package.json
if you get weary of running Wrangler manually:
deploy
: Deploy all three functionsdeploy:delete
: Deploydelete
functiondeploy:get
: Deployget
functiondeploy:list
: Deploylist
function
Run like regular NPM stuff, eg. npm run deploy
.