Forum Moderators: open

Message Too Old, No Replies

not caching files

swf's

         

Scally_Ally

1:44 pm on Sep 29, 2005 (gmt 0)

10+ Year Member



Hi all,

Does anybody know how i force a page not to cache any files, or at least swf's?

I have made a CMS in ASP, of which it is controlling what is viewed in the swf. The problem is that when you add content the swf does not update unless you clear the temporary internet files and press refresh.

Surely there is a way round this

Thanks

mrMister

5:19 pm on Sep 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Create a wrapper file (eg. yourflashfile.aspx) and in that you need to do a binary read on your .swf and then do a binary write, so your ASP.Net file outputs your SWF file.

You will also need to set the mime header to application/x-shockwave-flash

Then add the following line to the top of your code...

Response.Cache.SetCacheability(HttpCacheability.NoCache)

However, i'd advise you not to disable caching completely, as you're going to degrade performance. You can still cache the file but update the cache whenever the data you are depending on changes. That's by far the better option.

Once you've done that, update your HTML to point to the wrapper for the SWF file rather than the SWF file itself.

Unless you use a COM component, you can't do binary writes in classic ASP as far as I know.


private void Page_Load(object sender, System.EventArgs e)
{
//Disable cacheing

Response.Cache.SetCacheability(HttpCacheability.NoCache);

//Set the appropriate ContentType.
Response.ContentType = "application/x-shockwave-flash";
//Get the physical path to your flash file.
string FilePath = MapPath("yourflashfile.swf");
//Write the file directly to the HTTP content output stream.
Response.WriteFile(FilePath);
Response.End();
}


I think that code will work. Hower do read up on ASP.Net cacheing to improve the cacheing rather than disabling it completely

Easy_Coder

6:36 pm on Sep 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check the Response Object. I believe that there is a BinaryWrite method...

Scally_Ally

8:08 am on Sep 30, 2005 (gmt 0)

10+ Year Member



thanks for the response.

I have done the cms in old asp not .NET, will what mr Mister described still work for ASP?

I have tried a few things other than this, one with HTML where i used a meta tag to not cache any files like so

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">

but this did not work. I have also tried using the response object on the page that is pulling in the SWF, like so.

If anyone has any other ideas please let me know. Also is there a way that i could disable caching from the SWF?

I dunno....

Thanks

<% Response.CacheControl = "no-cache" %>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %>

but again this did not work.

mrMister

10:25 am on Sep 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have tried a few things other than this, one with HTML where i used a meta tag to not cache any files[ ...] but this did not work.

Of course it won't work, it's not the caching of the HTML that is the proplem. It's the SWF that is being cached that's causing a problem!

It doesn't matter that your CMS is written in ASP. Your SWF wrapper can be written ASP.Net and your CMS can remain in ASP. As I said before, ASP can't do Binary Writes without using a COM object.

Scally_Ally

2:32 pm on Oct 3, 2005 (gmt 0)

10+ Year Member



i have found a really easy way to get round the problem, (think i was too scared to touch .NET!).

in the actionscript file that call the results from the database simply set an identifier to the padge that is being called.

"http://www.example.com/content.asp?n="+new Date().getTime()

that sorted the problem for me

Cheers

[edited by: Xoc at 12:28 am (utc) on Oct. 27, 2005]
[edit reason] changed to use example.com [/edit]