douyuan4697 2013-02-11 01:08
浏览 6

too long

I am trying to get several resource files from the server using one http request. The set of resource files is different on every http request. So the zip file needs to be created dynamically.

The best idea I have so far is to:

step1: Create a zip file containing the desired resource files using php. Similar to this http://davidwalsh.name/create-zip-php

step2: send the .zip file to the client in the browser and parse the files.

Is this the best way to do this? How do I pass a zip file to javascript and how can I store the contents of the zip file?

  • 写回答

1条回答 默认 最新

  • donglu1971 2013-02-11 01:47
    关注

    HTTP already supports gzip compression:

    GZIP is usually more effective at compressing redundancies in files, which produces better compression when you have files that contain similar or repetitive information.

    GZIP Support: http://www.vervestudios.co/projects/compression-tests/results

    Since you need multiple files, you should tar them together before gzipping them, which you can do with PHP and PEAR's tar archive support. Then you can un-tar the files with javascript and the browser automagically handles gzip decompression.

    Here's an article on the difference between zip and gzip:

    Summary:

    1. GZIP can achieve better compression compared to ZIP.

    2. ZIP is capable of archiving and compressing multiple files, while GZIP is only capable of compression.

    3. You can easily extract individual files from a large ZIP file, but not from a GZIP tarball.

    4. ZIP is fairly popular on Windows, while GZIP is more popular on UNIX-like operating systems.

    http://www.differencebetween.net/technology/difference-between-zip-and-gzip/

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度