Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

egorbarisovi4's avatar

Cache of images with Inertiajs

Hello everybody!

I use Inertiajs with vue3 for frontend, laravel for backend.

My Issue :

My images that load on site from admin section is not updatet from server. insted of this behavior my browser upload this images from cache.

i use for upload images next code

<img :src="/images/dir/image_name.jpg" :alt="foo.name">

Path for it image : /public/dir/image_name.jpg

My HandleInertiaRequests@version method :

    public function version(Request $request)
    {
        return parent::version($request);
    }

Tell me please

  • What is the reason for this behavior?
  • How to download images from the server?
0 likes
2 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

You are not using inertia to load the image so it cannot cache bust it. You need to add some sort of ID to the image to have the cache bust

<img :src="/images/dir/image_name.jpg?v=1" :alt="foo.name">

Personally I would send the image path + ?v=something from the backend (or use vite that just handles it in Javascript)

1 like
egorbarisovi4's avatar

@Sinnbeck Yes, you are right. I'm not careful. It is not inertia. Could you show an example of loading images on inertia using middleware?

Please or to participate in this conversation.