Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Rudimentary cache suitable for APIs or similar endpoints using edge functions and KV, an edge key-value store

Notifications You must be signed in to change notification settings

mikaelvesavuori/api-cache-cloudflare-workers-kv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API cache using Cloudflare Workers and KV

This repository contains a rudimentary cache suitable for APIs or similar endpoints.

It has three functions:

  • Get (expects x-api-key header to be passed to origin; easy to remove if you don't like it)
  • Delete
  • List

Prerequisites

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.

Develop and test

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.

Deployment

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 functions
  • deploy:delete: Deploy delete function
  • deploy:get: Deploy get function
  • deploy:list: Deploy list function

Run like regular NPM stuff, eg. npm run deploy.

Resources

About

Rudimentary cache suitable for APIs or similar endpoints using edge functions and KV, an edge key-value store

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published