nuxt-hub / core

Build full-stack applications with Nuxt on CloudFlare, with zero configuration.
https://hub.nuxt.com
Apache License 2.0
993 stars 57 forks source link

feat: support cache expiration & improve admin speed #313

Closed atinux closed 1 month ago

atinux commented 1 month ago

By having our own nuxthub unstorage driver , we can now

The Cache admin dashboard is now much faster for new cache entries as it will read the metadata from the list instead of fetching the cache entry for each item 🚀

I also updated the module to always run the Cloudflare platform proxy in development, this is needed for storing the cache in local KV as it support expiration and bring consistency with production. Also, we don't support (and won't) remote storage for cache entries for performance reasons.

This brings a powerful feature from Cloudflare as we can now access event.context.cf from the server and API routes:

export default eventHandler(event => {
  export default eventHandler(async (event) => {
  const { isEUCountry, continent, city, timezone, country, region, latitude, longitude, botManagement } = event.context.cf
  return {
    continent,
    isEUCountry,
    country,
    region,
    city,
    timezone,
    latitude,
    longitude,
    botManagement
  }
})
pkg-pr-new[bot] commented 1 month ago

Open in Stackblitz

pnpm add https://pkg.pr.new/nuxt-hub/core/@nuxthub/core@313

commit: ff14a0e

cloudflare-workers-and-pages[bot] commented 1 month ago

Deploying playground with  Cloudflare Pages  Cloudflare Pages

Latest commit: ff14a0e
Status: âœ…  Deploy successful!
Preview URL: https://4833154c.playground-bhb.pages.dev
Branch Preview URL: https://feat-cache-speed.playground-bhb.pages.dev

View logs

robert-hoffmann commented 1 month ago

I think something in this just broke this: https://github.com/nuxt-hub/core/issues/316