PDA

View Full Version : how to NOT cache dynamic data ???


fantasio
06-12-2005, 08:51 PM
hi there,

i'd like to know if there is a way to prevent the caching of dynamic POST data.
here is the deal:
i created a many flash sites that get all of their content (links, texts etc.) from a xml file which is streamed via php.
i just realized, that this xml which gives away a lot of information, which i wouldn't necessarily let the user know ( like links to movies/mp3s the clients usually don't want to "share" unless from the web page) is cached completely. also other POST data like server queries are cached...
now is there a way to prevent that from happening ?

thanks m8tes

mmm..pi..3.14..
06-12-2005, 09:28 PM
Never needed to use it before, but it looks promising...

Look under the sections that talk about the "no-cache" part ;)

http://us2.php.net/manual/en/function.header.php

fantasio
06-12-2005, 09:51 PM
thanks,
but i tried this already, and it seems that all those tricks don't work...
no matter what i try. the POST data gets cached, so maybe flash is managing the caching and ignores all that no-cache stuff ?

hmmmm

mmm..pi..3.14..
06-12-2005, 10:11 PM
can you post some code that your using where the data is being cached? If I can get it to cache data on my side I can mess around with it for a while and try to figure something out :)

fantasio
06-12-2005, 11:14 PM
the code i'm using :
in flash:

var dataXML = new XML ();
dataXML.contentType = "text/xml";
dataXML.xmlDecl = "<?xml version='1.0' encoding='UTF-8' ?>";
dataXML.ignoreWhite = true;
dataXML.onLoad = function ()
{
doWhatEverYouLikeNow ();
};
var lv = new LoadVars ();
lv.filepath = "../xml/mydata.xml";
lv.sendAndLoad ("../php/data.php", dataXML);


in php:

$filepath =$_POST["filepath"];
$cnt = file_get_contents ($filepath);
print $cnt;


for the mydata.xml you can use whatever file you like

mmm..pi..3.14..
06-13-2005, 02:24 AM
Well I changed your PHP script to the following, and while it didn't prevent caching of the swf file, it did prevent caching of ALL the other files involved in the process, including html files and XML files. Is that what you needed?


<?php
header("Cache-Control: no-store, no-cache, must-revalidate");
$filepath =$_POST["filepath"];
$cnt = file_get_contents ($filepath);
print $cnt;
?>


Eric :)

fantasio
06-13-2005, 02:47 AM
cool!

at least in safari, firefox and opera it works !!!
of course the internet exploder ignores it... (have to check on the pc version though)
thanks mate!

gregback
06-23-2005, 04:29 PM
Any solution for Internet Explorer - unfortunately, some people still use this browser.

xxlm
06-23-2005, 10:43 PM
why not putting, like the old way, a var after the path
like

lv.sendAndLoad ("../php/data.php?nocache="+getTimer(), dataXML);

like this you'll never get any cache for sure...

mmm..pi..3.14..
06-24-2005, 04:28 AM
that was my initial thought xxlm, but I think they're wanting to not cache the swf file at all, to prevent access from people just opening the folder and copying the swf to the desktop or using a decompiler on it. While that way prevents caching so it doesn't load the same swf twice, it wouldn't prevent an swf with a different name from going to the temporary internet files, it would just give each swf that's cached a different name, like movie.swf?UniqueID=64364237...make sense?? The weird thing is that the PHP script I posted won't allow HTML/PHP files to be cached, but it will allow swf files...strange indeed :confused:

Eric

xxlm
06-24-2005, 05:32 AM
This is what I'm using usaually

// HTTP headers, no caching
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Pragma: no-cache'); // HTTP/1.0

xxlm
06-24-2005, 05:36 AM
and pi, yes after re-reading the post I got this...
But even if there is no cache, the decompiler will be able to get the swf...

fantasio
06-24-2005, 11:18 AM
@xxlm:

even if you use
lv.sendAndLoad ("../php/data.php?nocache="+getTimer(), dataXML);

the data gets cached in exploder, only difference is, that all the time you load the site, the file gets loaded again.

BTW I don't care anymore about decompilers, because i am using SWF Encrypt 3.0 now :)