--- Tony Tzankoff <[EMAIL PROTECTED]> wrote: > I have a webpage written in the latest version of PHP and need > a little bit of help with a rather pesky cache issue. Part of > the source code is as follows: > > page.php > <? > echo "<meta http-equiv=pragma content=no-cache>"; > echo "<meta http-equiv=expires content='-1'>"; > echo "<embed src=filename.mp3 autostart=true>"; > ?> > > The page does not cache (which is good), but the MP3 file does > (which is bad). Is there a way to NOT cache the MP3 file? I > would like to keep the file embedded within the page, if > possible. Thanks!
In order to understand this behavior, you need to understand how the Web works, including a little bit about HTTP. First, as an aside note, if you are using PHP, there is absolutely no reason to set HTTP headers using the HTML meta tag. This is equivalent to the HTML in your example code: header('Pragma: no-cache'); header('Expires: -1'); Since Pragma is an HTTP/1.0 header, might I also suggest: header('Cache-Control: no-cache'); Now, you are wondering how you can have all of these headers, yet the MP3 is still cached. That's because these headers are not sent when the MP3 is requested. The filename ends in .mp3, so PHP plays no role whatsoever (unless you have done something weird to force PHP to parse files ending in .mp3). When a Web clients sends the HTTP request for your page, it will receive something like this in the content of the response: <meta http-equiv=pragma content=no-cache> <meta http-equiv=expires content='-1'> <embed src=filename.mp3 autostart=true> Basically, the content is the output of your script, right? *This* is the stuff that won't get cached. Now, "filename.mp3" is just some text in the response at this point. There is no MP3 actually embedded into the HTML somehow. The browser parses the HTML and notices that it needs another resource, filename.mp3. Because there is no path specified, the browser will send a request for this resource using the same path as its parent (the page that is not going to be cached). The server will return this file in an HTTP response, and the headers in this response have nothing to do with your PHP script that was requested a few seconds ago. That is history. So, this is why the MP3 is cached while your HTML is not. Hope that helps. Chris ===== Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php