The first approach is to prefix the file names with a version-release string, and create symlinks to the files during installation or the first execution. Many systems have a version identification mechanism.
To manage the symlinks, the following could be used:
for g in $(find *.$1 -maxdepth 1 -type l);do
rm -f $g
for g in $(ls *.$1); do
ln -s $g $2.$g
for f in 'js' 'css'; do
pushd $f > /dev/null
fcreatenew $f $version
popd > /dev/null
httpd.conf (or equivalent)
# Cache js and CSS files for 6 months - with a timestamp
ExpiresDefault "access plus 6 months"
Header set Cache-Control "max-age=15552000"
RewriteRule (.*)/[0-9]+\.(.*)$ $1/$2
Timestamp Management Code (PHP)
$sTimestampFile = 'cache/timestamp';
$sRetVal = file_get_contents($sTimestampFile);
$sRetVal = time();
Once the timestamp is set, it is cached in the cache/timestamp file. In this system, the cache is cleared when new releases are installed, so the absence of the timestamp file ensures an update and a new set of requested files.
The timestamp can applied to .js and .css file requests like so: