paicha
V2EX  ›  问与答

Safari 为何无法缓存 MP3 文件?

  •  
  •   paicha ·
    PRO
    · Mar 2, 2015 · 3393 views
    This topic created in 4120 days ago, the information mentioned may be changed or developed.
    无论是移动端还是桌面端的 Safari ,在检查器中查看网络请求,发现 MP3 总是重新下载了。

    这种情况在桌面端的 Chrome 上不会出现,全部资源都缓存了。
    但是在移动端的 Chrome 又出现了 MP3 不能缓存的问题。

    使用 HTML5 的离线缓存可以解决 MP3 缓存的问题,但是整个 HTML 页面被缓存了,而且更新麻烦。

    若找不到其他解决方法,初步想通过 base64 编码,把音频文件转码储存在 Local Storage,再提取播放。
    Supplement 1  ·  Mar 2, 2015
    base64 编码的 MP3 在移动端播放不了。还是不折腾了,取消音频的默认加载。
    5 replies    2015-03-02 20:12:21 +08:00
    paicha
        1
    paicha  
    OP
    PRO
       Mar 2, 2015
    文件 HEAD 信息如下

    Expires: Fri, 02 Oct 2015 06:54:51 GMT
    Date: Thu, 02 Oct 2014 06:54:51 GMT
    Server: nginx
    Content-Type: audio/mpeg
    Content-Length: 1728984
    Cache-Control: max-age=31536000
    Last-Modified: Wed, 21 Jan 2004 19:51:30 GMT
    Age: 13051088
    Via: 1.0 gdfsdx80:88 (Cdn Cache Server V2.0),1.0 jy16:5011 (Cdn Cache Server V2.0)
    Connection: keep-alive
    paicha
        2
    paicha  
    OP
    PRO
       Mar 2, 2015
    搜索到:
    http://createjs.com/Docs/SoundJS/classes/HTMLAudioPlugin.html

    iOS 6 limitations
    can not cache the audio
    # 测试使用的是 iOS 8

    Android Chrome 26.0.1410.58 specific limitations
    Sound is not cached
    # 我测试的时候是40.x 的版本
    kacong
        4
    kacong  
       Mar 2, 2015
    估计是为了版权保护的原因。FF应该可以吧。
    paicha
        5
    paicha  
    OP
    PRO
       Mar 2, 2015
    @kacong 不是吧……
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1349 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 17:18 · PVG 01:18 · LAX 10:18 · JFK 13:18
    ♥ Do have faith in what you're doing.