Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic Edge Cache Middleware #51

Open
jrf0110 opened this issue Jun 20, 2021 · 0 comments
Open

Generic Edge Cache Middleware #51

jrf0110 opened this issue Jun 20, 2021 · 0 comments

Comments

@jrf0110
Copy link
Owner

jrf0110 commented Jun 20, 2021

It shouldn't matter where the Response came from, the edge cache middleware should be able to cache it and serve it early in the middleware chain.

// These would be our cache middleware options
type CacheOptions = {
  getCacheKey?: (req: URL) => string
  cache?: typeof caches.default
  edgeTTL?: number
  browserTTL?: number
  edgeTTLForHTML?: number
  browserTTLForHTML?: number
  allowedMethods?: Method[] 
}

import { Router, cache } from '8track'

const app = new Router()

// Cache all GET requests
app.get`(.*)`.use(cache())
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant