简体   繁体   中英

Laravel 5.2 - How to render page before all content load

I've another question about Laravel.

I've got gallery in my project which loads a lot of images (currently it's about 80 but it will still grow). The way I'm loading images is easy - in controller I get all the records from photos table and just passing them to view. In view I have foreach loop which shows every image.

The problem is that Laravel is probably caching the rendered page and then loads it. It causes gallery page long lasting loading (now between 5-10 sec depends on server load).

Am I right that it firstly caches the rendered page and then loads it? Will using faster caching package solve the problem? Or is there any other way to speed up site loading?

Thanks in advance!

What you want goes beyond Laravel and the slow load time is due to the amount of time it takes for the client to download the images. (Unless of course you are sending the images in base64 which would be quite strange in this case.)

Here is how others have solved this problem:

  • Create thumbnails for all the images and full size images are viewed after a thumbnail link is clicked.
  • Use a JavaScript to load the images.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM