douqiang6448 2014-08-13 22:13
浏览 34
已采纳

概念:为什么不使用数据:除了feed / API / utility之外的所有src的图像? 有PHP脚本吗?

Theorizing here on how to get lightning fast media + prevent hotlinking and the <img src="data:image-kj134332k4" /> is coming to mind and more. Scrapers dont need our src and real clients need instant load (esp cell net). Considering the recent google https-everywhere move, this would drastically decrease handshakes as well.

  • What disadvantages are there to crafting lists such as ecom categories/widgets/slideshows using data:image?

  • Is there any implications to extra KB of actual source code over serving vastly larger total page size?

  • Do ya'll prefer any PHP data:image gen script over another for parsing images as data as data at certain controller levels (leaving standard src images in other areas)?

  • Are there caching/CDN concerns? Would the parse wonk cache somehow? Seems not but im not cache expert.

Any guidance or case thoughts are much appreciated. Thank you!

  • 写回答

1条回答 默认 最新

  • duanji1026 2014-08-13 22:31
    关注

    Generally, the idea is worth considering, but in most cases the problems outweight the benefits.

    It is true that these images won't be cached on the client side anymore. Especially Expires-based caching saves you tons of bandwidth.

    As a rule of thumb I'd say: If these are small images that change frequently, embedding is a good idea. If images are larger and clients load the same image more than once in subsequent request, do by all means deliver images separately and put some effort into caching.

    As for the other points:

    1. Most browsers support this; however, some old IEs don't … so think of a fallback solution or be ready to get bug reports (may be neglible, depending on your user base.)

    2. The number of SSL handshakes is neglible, if you're using HTTP keep-alive, which is standard. Follow-up requests do indeed require a new handshake, but if you cache properly (see next point) and maybe put static files on a CDN, this is no problem.

    3. Read about caching, especially the Expires/Cache-Control headers and their friends.

    4. If you decide to embed, you don't really need a generator script, embedded images are base64 coded image files; this shouldn't take more than 3 lines of code.

    5. However, if you process/convert your images in PHP, there's even another disadvantage: Instead of statically serving them (maybe even from a different machine or CDN), images have to be on the same machine and go through the PHP engine, thus increasing the used memory of each process that serves a page with these images.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法