开发者

Prevent Opera form caching mp3

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, m开发者_开发问答ust-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?


This issue can be caused by server itself, to prevent file caching try to add some extra parameter to file name like:

$file = $_GET['file'] . '.mp3?' . time();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜