Plus one for the hash method. If you're frequently updating the entire
application (we release ours as a source code checkout of a specific branch)
then the modified times of the files are going to change as well.

The hash method ensures that your users aren't going to needlessly
re-download content if it hasn't actually changed.

Depending on the load on your site it may be acceptable to reference a
filename like so: styles.css?<?php echo md5file( 'style.css' ); ?>

Cheers,

- Bob -


On 27/08/2011, at 9:30 AM, Michael Robinson <[email protected]> wrote:

One could append a hash as a GET parameter to the CSS file in the head -
using a different hash when the CSS is updated. Or one could change the name
of the CSS file whenever it is updated.

Stack overflow has a good description of how one could achieve this in PHP:

What is an elegant way to force browsers to reload cached CSS/JS
files<http://stackoverflow.com/questions/118884/what-is-an-elegant-way-to-force-browsers-to-reload-cached-css-js-files/118886#118886>
?

Or one could use mod_pagespeed <https://code.google.com/p/modpagespeed/>,
which can be configured to do this automagically.

Mike

-- 
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]

Reply via email to