How can I use deflated/gzipped content with an XHR onProgress function?

前端 未结 8 2375
醉酒成梦
醉酒成梦 2020-12-08 00:11

I\'ve seen a bunch of similar questions to this get asked before, but I haven\'t found one that describes my current problem exactly, so here goes:

I have a page whi

8条回答
  •  悲&欢浪女
    2020-12-08 00:52

    Don't get stuck just because there isn't a native solution; a hack of one line can solve your problem without messing with Apache configuration (that in some hostings is prohibited or very restricted):

    PHP to the rescue:

    var size = ;
    

    That's it, you probably already know the rest, but just as a reference here it is:

    
    

    Live example:

    Another SO user thinks I am lying about the validity of this solution so here it is live: http://nyudvik.com/zip/, it is gzip-ed and the real file weights 8 MB



    Related links:

    • SO: Content-Length not sent when gzip compression enabled in Apache?
    • Apache Module mod_deflate doc
    • PHP filsize function doc

提交回复
热议问题