[Feature request] Purge sub-request cache #1270
Replies: 2 comments 2 replies
-
tl;dr - I don't think this is something we want to introduce into Hydrogen. The distributed nature of web applications is not suited for this feature, and the combined use of Modern platforms like Oxygen and Cloudflare Workers provide a caching API which is bound to a geographical collocation. This means that cache is not shared or distributed globally. This makes it impossible to globally purge a given cache entry, short of using that platform's tooling specifically for that purpose. Yes, you could send a webhook to your site — but it would only purge the entry for the closest colo that handles the request. We recommend using If the above strategy does not scale for a given API, I would recommend that the developer create a separate thin proxy service backed by a consistent, persisted cache like Redis. Another option is of course to use something like Gatsby, which is SSG by nature, or Next.js's new incremental static revalidation + SSG. |
Beta Was this translation helpful? Give feedback.
-
@jplhomer I'm investigating using Hydrogen as a head for our headless Shopify. We mix commerce and content at the moment we use NextJS for the ISR and SSG functionality for content and then regular on edge caching for the ecom sections. I was wondering if SSG or ISR was something you were considering for Hydrogen and Oxygen? If you're allowed to say :) |
Beta Was this translation helpful? Give feedback.
-
It would be awesome to be able to programatically bust sub-request cache. Something like:
Raised by a merchant who was worried about time-based caching eating into their third party CMS' usage cap. If they set the maxAge too low, they eat into their usage cap, if they set it too high they risk stale data.
A feature like this would allow them to set a high maxAge and purge when notified of content updates from a webhook.
Beta Was this translation helpful? Give feedback.
All reactions