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.

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

报告相同问题?

悬赏问题

  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏