tomaas
tomaas

Reputation: 129

cache way to work in flash pages

Each time I publish new content on my flash page, the computers that had opened that page earlier (with old content) remain with the same old content, until their histories are removed, or the page is refreshed with SHIFT+reload.

How can I build I page so this does not happen?

thanks a lot.

salu2

Upvotes: 1

Views: 116

Answers (2)

Jakub Slaby
Jakub Slaby

Reputation: 331

There are a few ways of making sure your files are not taken from user's cache. You can do it from PH by setting a expiration date but you can also do it from ActionScript.

The simpliest way is to add some strings to the file url after the "?" mark to get for example:

http://path.to.my.file/file.swf?cacheBuster=123092183120

It will make sure that the url is different so it won't get the file from cache. The best way is to get a current datestamp. You can also specify a site version number and update it when you upload new files and then add the version number to the url.

This will allow you to make sure that the files are loaded from the server when you update your site but when a user enters the page again and there were no changes the file will load from cache.

http://path.to.my.file/file.swf?version=1.1.0

this is the code I use in my projects:

var _url:String = "http://some.url/file.swf";
var vstring:String = (_url.indexOf("?") != -1) ? "&version=" + _version : "?version=" + _version;
_url = _url + vstring;

Upvotes: 4

shanethehat
shanethehat

Reputation: 15570

You can add cache control headers to your HTML page using some server-side scripting. Here is a PHP example:

<?php
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

By setting the date in the past you force the browser/proxy cache to check if the files have changed since they were last cached.

Upvotes: 2

Related Questions