Forum Moderators: phranque
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]
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
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.
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.
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.