Skip to content

IPX max-age configuration doesn't apply #992

Open

Description

@yuzu-qroulland

Hello,

I'm unable to increase the cache max-age of my images.

With the help of #704 , I've tried to define it via the image config with that code but it's not working.

image: {
    ipx: {
      maxAge: 60 * 60 * 24,
    },
  },
Capture d’écran 2023-09-18 à 09 39 45

I'm using nuxt:3.7.3 and @nuxtjs/image:1.0.0-rc.2

Activity

  1. urbgimtam commented on Sep 19, 2023

    @urbgimtam

    Interested on this too.
    Not sure if the reproduction helps. It's always giving me a max-age of "31536000", no matter the maxAge value passed in config.

    https://stackblitz.com/edit/github-ac11u5?file=app.vue

  2. Pierre-Saigot commented on Sep 22, 2023

    @Pierre-Saigot

    Same..

  3. krthr commented on Sep 25, 2023

    @krthr

    Same

  4. yuzu-qroulland commented on Sep 29, 2023

    @yuzu-qroulland
    Author

    Hi everyone,

    I'm coming back to you because I've found a solution in the meantime. 🥳

    With the following statement the maxAge is well taken into account:

    image: {
        ipx: {
            options: {
                maxAge: 31536000,
            },
        },
    }

    Just need to set the maxAge into an options object. 🧐

    However, I don't know whether this is the expected behavior and therefore the documentation is out of date, or whether it's a design error. 👀

  5. manchenkoff commented on Oct 1, 2023

    @manchenkoff

    @yuzu-qroulland yep, that works! thanks 👍

  6. rahulkumarsingh73690 commented on Nov 16, 2023

    @rahulkumarsingh73690

    Any update? @yuzu-qroulland

    Nothing worked for me

  7. manchenkoff commented on Nov 16, 2023

    @manchenkoff

    just fyi, since I upgraded to Nuxt 3.8 it works even with default config like

    image: {
        quality: 80,
        format: ['avif'],
        ipx: {
            maxAge: 60 * 60 * 24 * 365,
        },
    },
  8. rahulkumarsingh73690 commented on Nov 16, 2023

    @rahulkumarsingh73690

    Thanks @manchenkoff for sharing.

    My app is hosted in Digitalocean app platform and this is not working for me

    image

    Nuxt - 3.8
    Nuxt/image - 1.0.0

  9. cernymatej commented on Nov 25, 2023

    @cernymatej
    Member

    Now the options key seems to have been removed from IPXRuntimeConfig and it doesn't work at all for me 😕
    Nuxt - 3.8.2
    Nuxt/Image - 1.0.0

  10. raphaelbernhart commented on Jan 2, 2024

    @raphaelbernhart

    For me it is working with the following config:

    image: {
            ipx: {
                maxAge: 60 * 60 * 24 * 365,
            },
        },
    
    - Operating System: Darwin
    - Node Version:     v18.19.0
    - Nuxt Version:     3.9.0
    - CLI Version:      3.10.0
    - Nitro Version:    2.8.1
    - Package Manager:  pnpm@8.12.1
    - Nuxt Image:       @nuxt/image@1.1.0
    
  11. damvik commented on Jan 24, 2024

    @damvik

    I am currently facing a similar issue, but it seems to be limited to external domains.

    Image from external domain
    image

    Images from public dir
    image
    image

    dependecies

    {
      "devDependencies": {
        "@nuxt/devtools": "latest",
        "@nuxt/image": "^1.3.0",
        "@nuxtjs/fontaine": "^0.4.1",
        "@nuxtjs/google-fonts": "^3.0.2",
        "@nuxtjs/i18n": "^8.0.0",
        "@nuxtjs/tailwindcss": "^6.10.0",
        "@tailwindcss/forms": "^0.5.7",
        "@vueuse/core": "^10.7.0",
        "@vueuse/nuxt": "^10.7.0",
        "nuxt": "^3.9.3",
        "nuxt-icon": "^0.6.8",
        "nuxt-svgo": "^4.0.0",
        "vue": "^3.4.15",
        "vue-router": "^4.2.5"
      },
      "dependencies": {
        "@pinia/nuxt": "^0.5.1",
        "@splidejs/vue-splide": "^0.6.12",
        "photoswipe": "^5.4.3",
        "pinia": "^2.1.7",
        "qs": "^6.11.2",
        "vue-multiselect": "^3.0.0-beta.3"
      }
    }

    nuxt.config.ts

    export default defineNuxtConfig({
      image: {
        provider: "ipx",
        ipx: {
          maxAge: 60 * 60 * 24 * 365,
        },
        domains: ["cms.kuvqfitjqf.cfolks.pl"],
        presets: {
          default: {
            modifiers: {
              quality: 90,
              format: "webp",
            },
          },
        },
      },
    })

    I am aware that this functionality was functional in the past. An illustrative example can be found at the following link: https://stackblitz.com/edit/github-ac11u5?file=app.vue.
    image

    @pi0 Could you help me solve the problem?

  12. kytosai commented on May 25, 2024

    @kytosai

    I am currently facing a similar issue, but it seems to be limited to external domains.

    Image from external domain image

    Images from public dir image image

    dependecies

    {
      "devDependencies": {
        "@nuxt/devtools": "latest",
        "@nuxt/image": "^1.3.0",
        "@nuxtjs/fontaine": "^0.4.1",
        "@nuxtjs/google-fonts": "^3.0.2",
        "@nuxtjs/i18n": "^8.0.0",
        "@nuxtjs/tailwindcss": "^6.10.0",
        "@tailwindcss/forms": "^0.5.7",
        "@vueuse/core": "^10.7.0",
        "@vueuse/nuxt": "^10.7.0",
        "nuxt": "^3.9.3",
        "nuxt-icon": "^0.6.8",
        "nuxt-svgo": "^4.0.0",
        "vue": "^3.4.15",
        "vue-router": "^4.2.5"
      },
      "dependencies": {
        "@pinia/nuxt": "^0.5.1",
        "@splidejs/vue-splide": "^0.6.12",
        "photoswipe": "^5.4.3",
        "pinia": "^2.1.7",
        "qs": "^6.11.2",
        "vue-multiselect": "^3.0.0-beta.3"
      }
    }

    nuxt.config.ts

    export default defineNuxtConfig({
      image: {
        provider: "ipx",
        ipx: {
          maxAge: 60 * 60 * 24 * 365,
        },
        domains: ["cms.kuvqfitjqf.cfolks.pl"],
        presets: {
          default: {
            modifiers: {
              quality: 90,
              format: "webp",
            },
          },
        },
      },
    })

    I am aware that this functionality was functional in the past. An illustrative example can be found at the following link: https://stackblitz.com/edit/github-ac11u5?file=app.vue. image

    @pi0 Could you help me solve the problem?

    I have same problem, setting max age for ipx dont work with external domain. Only work with public folder path

    Setting in nuxt config

    image: {
        domains: ['api.kytosai.com'],
        provider: 'ipx',
        ipx: {
          maxAge: 60 * 60 * 24 * 7, // 7 days
        },
      },
    

    External domain:

    image

    Public folder path

    image
  13. aetievant commented on Aug 13, 2024

    @aetievant

    I am currently facing a similar issue, but it seems to be limited to external domains.

    Image from external domain image

    Hello,

    I'm facing the exact same issue than @gnidustotalus and @kytosai here, not able to set Cache-Control header for external domains.

    Is there any news on a fix or at least a workaround? It's quite annoying to not be able to proxy cache images generated by IPX...

    Thanks!

  14. aetievant commented on Aug 13, 2024

    @aetievant

    I actually found a workaround which consist to deal with nuxt.config.js configuration and nitro route rules:

    export default defineNuxtConfig({
      // [...]
      nitro: {
        routeRules: {
          "/_ipx/**": { headers: { 'cache-control': `public,max-age=691200,s-maxage=691200` } },
        }
      },
      // [...]
    })

    Not optimal but currently I will live with this, until there is a real fix to solve that issue.

    Hope it helps!

  15. jlemonz commented on Mar 4, 2025

    @jlemonz

    Hi. How can i increase cache time when using vercel? Does this also work? RIght now its 3600s

  16. VasiliyRusin commented on Oct 16, 2025

    @VasiliyRusin

    @aetievant
    @kytosai
    @gnidustotalus

    Hey folks 👋

    By default, maxAge is ignored — it takes the value from the external domain, as you can see in this MR.
    Luckily, this follow-up MR gives us a way to control that behaviour.

    To make your custom maxAge actually work, you’ll need to set ignoreCacheControl: false:

    image: {
      ipx: {
        http: {
          maxAge: 60 * 60 * 24 * 365,
          ignoreCacheControl: false // <--- this one matters!
        }
      }
    }

    Unfortunately, @nuxt/image still overrides runtimeConfig, so you can’t set these values via env vars 😅
    But static config in nuxt.config.ts works just fine.

    This behaviour is still under-documented, and it would be great to have it clarified in the official documentation.

  17. lukas-pierce commented on Jul 7, 2026

    @lukas-pierce

    I just accidentally discovered that in nuxt.config.ts, maxAge for local images needs to be specified inside the fs object:

      image: {
        ipx: {
          maxAge: 1, // fallback
          fs: {
            maxAge: 2, // for local images
          },
          http: {
            maxAge: 3, // for remote images
          },
        },
      },
    Image

    @danielroe I think this should also be mentioned on the documentation page: https://image.nuxt.com/providers/ipx

    Also, if you use prerendering, for example:

    // nuxt.config.ts
    export default defineNuxtConfig({
      modules: [
        '@nuxt/image',
      ],
      image: {
        ipx: {
          maxAge: 31_536_000, // one year
          fs: {
            maxAge: 31_536_000, // one year
          },
          http: {
            maxAge: 31_536_000, // one year
          },
        },
      },
      routeRules: {
        '/': {
          prerender: true, // prerender home page in build time
        },
      },
    })

    then keep in mind that IPX images are generated at build time and placed into .output/public/_ipx directory.

    In production, these files may be served as static assets instead of going through the IPX server, so the IPX response headers will not be applied. In that case, you need to handle cache headers yourself.

    In my case, I use nginx as a reverse proxy. A simplified config could look like this:

    server {
      server_name lukas-pierce.com;
    
      location / {
        include snippets/nuxt-proxy.conf;
      }
    
      location ~* ^/_ipx/.*\.(avif|webp|png|jpe?g|svg|gif)$ {
        add_header Cache-Control "max-age=31536000, public, s-maxage=31536000"; # Same as IPX
        include snippets/nuxt-proxy.conf;
      }
    
      ... # other nginx settings
    }
  18. added theissue type on Nov 27, 2026
  19. added
    bug
    documentation
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdocumentationipxworkaround available

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions