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

feat: support cache expiration & improve admin speed #313

Merged
merged 13 commits into from
Oct 11, 2024
Merged

Conversation

atinux
Copy link
Contributor

@atinux atinux commented Oct 9, 2024

By having our own nuxthub unstorage driver , we can now

  • The cache entry metadata in KV metadata
  • Set the expiration of the item so Cloudflare will remove it automatically (works in development too!)

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
  }
})

Copy link

pkg-pr-new bot commented Oct 9, 2024

Open in Stackblitz

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

commit: ff14a0e

Copy link

cloudflare-workers-and-pages bot commented Oct 9, 2024

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

@atinux atinux merged commit 1204b40 into main Oct 11, 2024
7 checks passed
@atinux atinux deleted the feat/cache-speed branch October 11, 2024 12:55
@robert-hoffmann
Copy link

I think something in this just broke this:
#316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants