How to invalidate default nuxt/image cache
I have nuxt image setup with the default IPX provider, Currently I have the maxAge set to 1 hour but I would like to significantly increase this however to be able to do that I need to have a way to manually invalidate the cache should there be a need.
this is my config at the moment
How do I go about making an endpoint where I can invalidate specific images if required.
3 Replies
Hi @Kammah. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Short answer: there isn’t a documented, built‑in API in Nuxt Image/IPX to manually purge specific images from the default cache. The official docs cover configuration, providers, local/remote sources, and static generation, but they don’t mention cache invalidation endpoints or a purge mechanism you can call. I’m sorry, but the knowledge sources do not explicitly mention a way to invalidate the default IPX cache programmatically. [Providers; Configuration]
What you can do instead (workarounds/strategies):
- Bust the cache via URL changes: updating the image URL (e.g., adding a version/hash query like ?v=123) produces a new IPX key and forces regeneration. This aligns with how providers generate optimized URLs based on src and modifiers. [Providers; IPX]
- Use short maxAge during update windows, then increase it after assets settle. This doesn’t invalidate on demand, but helps operationally. The docs confirm you can configure providers and modifiers, but not a purge API. [Configuration]
- For static sites (nuxt generate), you can prerender specific IPX URLs so they’re re-generated on build (not a runtime purge, but ensures fresh output when you redeploy). [Static Images]
- If you deploy to a provider with its own CDN/image service (e.g., Netlify Image CDN), you might leverage that platform’s cache controls/invalidation instead of IPX. Nuxt Image can switch providers or auto-detect some environments. [Providers; Netlify]
If you need a true runtime invalidation endpoint, the knowledge sources don’t document one for IPX. You’d likely need a custom solution (e.g., versioned URLs, or switching to a provider/CDN that exposes purge APIs). If you can share your hosting environment, we can see if a provider integration supports cache purge flows.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@481766113663778826> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
I am happy to build the custom solution but in order to do this I need to know how the cache gets stored/using what mechanism and where so I can build a way to invalidate it correctly as looking through the code there is no mention of cache or cache keys for this type of scenario.
we have a custom hosting solution so none of the provider image services are relevant here