Hi,
In order to reduce the number of http requests to our server, we
decided to add a expire header to our assets files (images, css and
js), so that browsers cache it.
But there's an important side-effect due to the expire headers:
Indeed, when Apache will deliver our assets (images, css, js), it will
say something like "cache it for one year". But if the next release
include some updates of the images, css or js files, then browsers
will keep the old files (that was cached due to the expire header).
So we need to force browser to download the new version of our assets.
In order to force browser to load a new version of the file, we use a
known trick named "cache busting", that consist of concating a postffx
to the filename, like /path/to/my/image.png?1234
where the number after the question mark, is the assets versionning
(we use our svn changeset here)
So, we have to rewrite all path to our assets: images, css and js. To
do that, i only know 2 ways :
- redefining some helper functions with the Runkit pecl library (but
it may have some performance side-effects..)
- or copying the original AssetHelper of Symfony to our helper
directory (and here do our modification, but it's not really nice...)
To give you an idea, here a what the override actually does, in our
AssetHelper file:
function _compute_public_path($source, $dir, $ext, $absolute = false)
{
// original Symfony hoes here
return $source.$query_string . '?' . $assets_version; // e.g: 1234
}
Did you already implement such cache busting for your application?
Do you know a nicer way to override default Symfony helpers?
Best regards,
Guillaume Dufloux
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---