Forum Moderators: phranque

Message Too Old, No Replies

Cacheing of Flash files with .swf?var=aa

flash cache dynamic

         

Mondo

1:33 am on Feb 23, 2005 (gmt 0)

10+ Year Member



Hi all

We're serving a moderately sized Flash file (270Kb), which in turn loads a JPEG created by a user.

This is addressed by:

<object data="design-example.swf?userimage=jytjyukj042305... >

The JPEG's can be up to 100Kb in size; these are different for every user; the .swf file however is not, and will change possibly every month or so.

Our system (Apache on Linux) is serving up the .swf freshly every time a request is made - I am making the assumption that this is because of the appended variable name (?userimage=jytjyukj042305..). It would help the server immensely if I could find a way of checking only if the actual .swf file has been modified since last use.

I could even disable checking for the created/modified date since last accessed, as I can simply change the name of the .swf if the browser needs a fresh version.

<snip>

Hopefully this isn't too rambly! In a nutshell, how can I get our server to cache what looks like a dynamically generated file.

Thanks.

Mondo

[edited by: jdMorgan at 1:59 am (utc) on Feb. 23, 2005]
[edit reason] No specifcs, please. See TOS. [/edit]

jdMorgan

2:33 am on Feb 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mondo,

Welcome to WebmasterWorld!

You will need to re-architect the flash image inclusion. While you may be able to fix things on your server to support Squid proxy caching or similar (I assume that's what you meant), you won't be able to do anything to change the client browser behaviour. All modern browsers will treat /file?a and /file?b as two separate resources, and will fetch them and cache them separately. If you always provide a new query string, the browser will always treat it as a new request.

The only easy fix I can think of is to use a cookie to pass the user state back to the server, so that the URL does not need to include the query string.

Jim

Mondo

11:01 am on Feb 23, 2005 (gmt 0)

10+ Year Member



Hi Jim

Thanks for the response.

I just remembered where I got the idea from. I did read a while ago a method for cacheing dynamically generated images (somewhere), of the format:

<img src="image.php?id=319" />

I'm (crudely) guessing that browsers will treat the <object> tag in the same way as the <img> tag.

I'll see if I can find it again, or whether it was just a figment of my imagination.

If I get anything useful, I'll post the findings.

Thanks again.

Mondo.

buttoxicated

7:36 pm on Feb 23, 2005 (gmt 0)

10+ Year Member



A possible solution is to use the Flash function loadVariables instead. That way you don't have to use a query string in the object tag to obtain an external variable, so the .swf file gets cached correctly.

The downside is that it requires you to rewrite some parts of your site. But if you have a lot of visitors, it may save you enough bandwidth to be worth it.

Mondo

10:27 pm on Feb 23, 2005 (gmt 0)

10+ Year Member



My slight problem would be that I wanted to avoid the user having to type in anything to the Flash object (ie their image ID - this variable is generated by them uploading a picture, and the Flash movie then imports a jpeg based on that image ID.

It might be prudent however in the future to get them to just type this in, if it saves the bandwidth! Depends how many times they refresh the page.

Thanks for the tip - I'd forgotten about loadVariables.