2016-06-24 23:46
浏览 41

Laravel 5.2 - 如何在加载所有内容之前呈现页面

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!

图片转代码服务由CSDN问答提供 功能建议


我有画廊 在我的项目中加载了大量的图像(目前它大约是80但它仍然会增长)。 我正在加载图像的方式很简单 - 在控制器中我从 photos 表中获取所有记录,然后将它们传递给视图。 在视图中我有 foreach 循环,它显示每个图像。

问题是Laravel可能正在缓存渲染的页面然后加载它。 它导致画廊页面持续加载(现在在5-10秒之间取决于服务器负载)。

我是否正确它首先缓存渲染页面然后加载它? 使用更快的缓存包会解决问题吗? 或者还有其他方法可以加速网站加载吗?


  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongxu7408 2016-06-25 01:55

    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.
    打赏 评论

相关推荐 更多相似问题