防止 Opera 表单缓存 mp3
我再次尝试阻止从我的网站缓存 mp3 文件。我使用 flash 播放器,所有文件都在公共 html 之外,我使用这个脚本来访问文件
<?php
$file = $_GET['file'] . '.mp3';
$fileDir = '/path/outside/public_html/';
if (file_exists($fileDir . $file))
{
ob_start();
$contents = file_get_contents($fileDir . $file);
echo $contents;
$buffer = ob_get_contents();
ob_end_flush();
header('Expires: Mon, 26 Jul 1980 00:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Cache-Control: post-check=0, precheck=0', false);
header('Pragma: no-cache');
header('Content-type: audio/mpeg');
echo $buffer;
} ?>
,我是 php noob,所以这个脚本可能有错误,但它可以工作...几乎,我在阻止 Opera 中的文件缓存时遇到问题 - 它仍然缓存 mp3 文件。我看到了一些解决方案:当我从网站播放文件时,文件被下载到缓存,但完整下载后文件被自动删除。没有时间复制此文件。所以我的问题是:怎么做?这可以用 php 实现吗?
again i try to prevent form caching mp3 files form my site. I use flash player, all files are outside public html i use this script to access to files
<?php
$file = $_GET['file'] . '.mp3';
$fileDir = '/path/outside/public_html/';
if (file_exists($fileDir . $file))
{
ob_start();
$contents = file_get_contents($fileDir . $file);
echo $contents;
$buffer = ob_get_contents();
ob_end_flush();
header('Expires: Mon, 26 Jul 1980 00:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Cache-Control: post-check=0, precheck=0', false);
header('Pragma: no-cache');
header('Content-type: audio/mpeg');
echo $buffer;
} ?>
I'm php noob so this script is probably buggy, but it's work... Almost, i have problem to prevent file cache in Opera - it still cache mp3 files. I saw some solution: when i play files from site, file was downloaded to cache but after full download file was automaticly delete. There is no time to copy this file. So my question is: ho do this ? Is this possible with php?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此问题可能是由服务器本身引起的,为了防止文件缓存,请尝试在文件名中添加一些额外的参数,例如:
This issue can be caused by server itself, to prevent file caching try to add some extra parameter to file name like: