1
Vote

Cache buster based on file length

description

HI

i'm nearly finished with the new production site using assman. the tool has been great - fit for purpose in almost every way... except one!
i cannot deploy our site to production until we have support for a cache buster. this would be a querystring written after the javscript file containing the file length or similar. i can change the way assman generates scripts to include them in the build process...and then bust them here but it is awkward.
can you please add an attribute for the bundles in the config that simply says something like 'cachebust'. if this is set it should take the length of the combined files in characters, and add this as a query string.
we run in a load balanced environment, and at any time may deploy one file and leave the other files intacted. using mod dates won't work across the load balanced boxes, using any other hash won't work if we only deploy one file.

please let me know your thoughts - it would be a REAL shame to have to abandon/monkey patch assman at this late stage when all the other stuff works so well straight out of the box!

comments

andyalm wrote Oct 16, 2011 at 8:12 PM

Thanks for the feedback. If you pre-compile your assets/resources, then cache busting is supported. When the resources are compiled, it will automatically generate a version number (based on the date/time of the build) and automatically append that version number as a query string parameter when you include the script or stylesheet. If you want to use your own version number, you can set it as a property on the PreCompileResources task. Note that the current functionality is a little more limited than you proposed in that it uses the same version number for all resources. It would be nice if instead of generating a global version based on date/time, it would generate a unique hash for each resource based on the content of the resource. I hope to add this soon, and will keep this issue open as a reminder. In practice, unless you are releasing to production all the time, the global date/time version should be good enough. It just means when you release a new build to production, every resource will need to be redownloaded the first page hit by the user, even if some of the resources did not change.

For more information on precompiling resources, see this page: http://assman.codeplex.com/wikipage?title=Precompilation

I really do highly suggest that you precompile your resources. While Assman will perform adequately in Release mode without precompiling, it will perform even better when precompiling.