dongzhuo3376 2013-02-26 09:15
浏览 36

file_get_contents比iframe更快

Currently I'm loading a few external sites via iframe to showcase content. However since those sites are geographically far away from my users and my server, it's really really slow for them.

I recently came across the php method file_get_contents() and read that it would be faster since its server side scripts. My question is, from a user's perspective. Will file_get_contents load external sites faster for my users than iframe or is there some other php methods faster than iframe I can use.

Thanks

  • 写回答

3条回答 默认 最新

  • duandangqin0559 2013-02-26 09:20
    关注

    If you fetch all these sites on the server before sending anything to the client, the client will see nothing until your server has loaded every single page. If you use iframes, the client is loading the sites asynchronously and will see something earlier. If your server would periodically fetch these pages and cache them, you'd have an advantage.

    But, loading the sites on the server and embedding their HTML would also mean you'd have to do a lot of processing server-side to rewrite and fix all external includes these sites have (stylesheets, Javascript, images), since they're now being served from a different domain.

    In short: probably not.

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)