jeudi 28 juillet 2016

Laravel and intervention imagecache generate too many queries (1 query per image)

I'm using Laravel 5.1 with Intervention Imagecache

I'm writing a store, and the products page have many images. I'm using URL-based manipulation (e.g. accessing http://ift.tt/2ayyJnv generates a 255x135 version of some-image.jpg) for resizing the images. When the image is loaded, however, Laravel generates a query that checks the user (select * from users where users.id = ? limit 1)

The problem is that this query is generated every time any route in Laravel is accessed, including the Intervention Imagecache route, and when the page loads 20-30 images using Intervention, the above user-check SQL query is executed for every image (in this 20-30 times).

While I was trying to figure out the problem I noticed that this query is generated for every single route in Laravel, even a simple test route, in other words the problem is not with Intervention Imagecache itself.

I'm currently trying to disable the user-check query on the Intervention route but I'm yet to succeed.

My 2 questions are:

  1. Can the user-check query be disabled for a specific route?
  2. Is there a way around this query-per-image problem (except resizing images and saving them to the filesystem - in other words abandoning the URL-based manipulation)?


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire