No description
  • JavaScript 82%
  • HTML 18%
Find a file
2026-01-13 10:13:47 +08:00
.vscode Initial commit (by create-cloudflare CLI) 2026-01-13 09:08:58 +08:00
public Initial commit (by create-cloudflare CLI) 2026-01-13 09:08:58 +08:00
src feat: add cache and stale-while-revalidate handler 2026-01-13 09:50:51 +08:00
test Initial commit (by create-cloudflare CLI) 2026-01-13 09:08:58 +08:00
.editorconfig Initial commit (by create-cloudflare CLI) 2026-01-13 09:08:58 +08:00
.gitignore Initial commit (by create-cloudflare CLI) 2026-01-13 09:08:58 +08:00
.prettierrc Initial commit (by create-cloudflare CLI) 2026-01-13 09:08:58 +08:00
package.json feat: add cache and stale-while-revalidate handler 2026-01-13 09:50:51 +08:00
pnpm-lock.yaml feat: add cache and stale-while-revalidate handler 2026-01-13 09:50:51 +08:00
README.md doc: add more readme 2026-01-13 10:13:47 +08:00
vitest.config.js Initial commit (by create-cloudflare CLI) 2026-01-13 09:08:58 +08:00
wrangler.jsonc Initial commit (by create-cloudflare CLI) 2026-01-13 09:08:58 +08:00

Live Site

https://cloudflare-worker-express.ken-ng.workers.dev/

Deploy

pnpm run deploy

Validating Cloudflare Cache Flow

Cache Config

cdn-cache-control': 'max-age=120, stale-while-revalidate=60 cache for 120 seconds revalidate for 60 seconds

Testing

Try to click the random button multiple times Validate the HTTP response headers

Cloudflare Worker Log

Workers & Pages > select the project > Observability > Events Then click <Play Live> button to get the live logs

You will see something like

2026-01-13 09:43:06:218 GMT+8 | GET /random | Cache HIT
2026-01-13 09:43:06:218 GMT+8 | GET /random | Cache REVALIDATE  // <-- the age header exceed the stale-while-revalidate seconds
2026-01-13 09:43:06:218 GMT+8 | GET /random | Cache HIT
2026-01-13 09:43:06:218 GMT+8 | GET /random | Cache REVALIDATE
2026-01-13 09:43:06:214 GMT+8 | GET /random | GET https://cloudflare-worker-express.ken-ng.workers.dev/random
2026-01-13 09:42:46:600 GMT+8 | GET /random | Cache HIT
2026-01-13 09:42:46:600 GMT+8 | GET /random | GET https://cloudflare-worker-express.ken-ng.workers.dev/random
2026-01-13 09:42:46:600 GMT+8 | GET /random | Cache HIT