Long term caching for images
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 331
- Avg merge
- 19h 52m
- Merged PRs (30d)
- 9
Description
Versions
- nuxt: ^2.15.6
- nuxt/image: "^0.4.14",
Hey everyone and thank you for this great package.
I'm facing an issue with Lighthouse extension of chrome and i cannot fix it.

Here is my image component from the code:
<nuxt-img
src="/img/insurance/hero.jpg"
class="h-full w-full object-cover"
sizes="sm:375px md:768px lg:1024px"
height="400"
/>
and here is the generated code:
<img
src="/_ipx/img/insurance/hero.jpg?s=1024_400"
height="400"
sizes="(max-width: 640px) 375px, (max-width: 768px) 768px, 1024px"
srcset="/_ipx/img/insurance/hero.jpg?s=375_400 375w, /_ipx/img/insurance/hero.jpg?s=768_400 768w, /_ipx/img/insurance/hero.jpg?s=1024_400 1024w"
class="h-full w-full object-cover"
>
My image is stored inside static/img/insurance directory. I tried to fix the issue by using the render option in nuxt.config like this (but it didn't solve the issue):
render: {
// Setting up cache for 'static' directory - a year in milliseconds
static: {
maxAge: 60 * 60 * 24 * 365 * 1000,
},
},
I also tried the use of keep-alive prop in my layout like this(but it didn't solve the issue): <Nuxt keep-alive />
My question is this one:
Is there any way to set maxAge through nuxt/image configs? If not are there any plans of exposing the ability to do so?
If there is another solution that you are aware please let know (or let me know how i can help with this).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how the nuxt-img component turns the source image into the generated /_ipx URL and how nuxt/image handles its configuration. Compare that behavior with the attempted render.static maxAge setting; done means providing a supported way to configure long-lived caching for optimized images and confirming the resulting cache behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt, typescript
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100