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?
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)
@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.