views:

20

answers:

1

Hi, 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?

Regards and sorry for my english

A: 

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();
Nazariy
Thank you but this not work. I even don't get any error, just nothing happen.
Martin