我有一个小的swf播放器嵌入在JSP页面中,播放器在Chrome和FF中工作良好,它也在IE中工作,但只有在第一次访问后,如果我再次打开音频文件,音频不会播放,除非我按下暂停,然后再次播放,为了让它再次工作,我必须清除浏览器缓存。
我尝试阻止浏览器缓存(设置Pragma,Cache-Control...)但是它也不起作用!
发布于 2012-12-03 23:31:06
有两种方法可以解决这个问题:
更改请求mp3的代码或更改提供mp3文件的服务器的代码。
1-更改请求代码,使其每次请求时看起来都像是对缓存的不同请求。这将取决于您的mp3播放器。一些玩家允许这样做,而另一些则不允许。
<param name="url-to-mp3" value="mymp3.mp3?<%=System.currentTimeMillis() %>" />2-更改服务器代码。例如。在Servlet中,尝试添加以下标头,让浏览器知道您不希望缓存mp3。
// Set to expire far in the past.
response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
// Set standard HTTP/1.1 no-cache headers.
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
// Set standard HTTP/1.0 no-cache header.
response.setHeader("Pragma", "no-cache");我希望这能帮到你。
https://stackoverflow.com/questions/13686012
复制相似问题