Versioning?

83 views
Skip to first unread message

c frim

unread,
Oct 12, 2015, 4:11:52 AM10/12/15
to SquishIt
Hi all,

Does Squishit support versioning?
It would be nice if I could control when the client should download a new version of the 
js/css script instead of the cached file.

Alex Ullrich

unread,
Oct 15, 2015, 3:52:58 PM10/15/15
to SquishIt
Out of the box, SquishIt appends hashes based on the file content to all of the files that it manages.  This used to be MD5 but I believe 

You can plug in a custom hasher (if you wanted to store a release date in a config file or something to use instead and use that) but the default implementation should work.

You can configure it using something like this in Global.asax.cs App_Start method:
    
Bundle.ConfigureDefaults().UseHasher(new MyCustomHasher());

Hope this helps,

Alex 
 

c frim

unread,
Oct 20, 2015, 12:52:35 PM10/20/15
to SquishIt
Thanks a lot, Alex!

I'll try that out. Can you tell me, what the MyCustomHasher should contain?

Thanks in advance.

Casper

Alex Ullrich

unread,
Oct 21, 2015, 10:41:47 AM10/21/15
to SquishIt
Thats kind of up to you to decide :)

All SquishIt cares about is that it implements the IHasher interface - whatever string you return will be appended to the querystring for versioning so make sure it is properly escaped if necessary.

If you want to base it on deployment date, you could probably put that in your configuration file or something.  Could also infer it based on the most recent date modified in your bin directory or something like that.

Is there a specific problem you're having with the built in versioning?  It has always worked very well for me.  If you are having issues with proxies stripping querystring parameters or something, you may want to look into including the hash as part of the filename itself (just render to myfile-#.js and the # will be replaced with the hash).  Its a little more work (requires setting up the appropriate rewrite rules) but you can also include the hash as a folder in the path.  Take a look here for a breakdown of the different options http://blogs.lessthandot.com/index.php/webdev/serverprogramming/using-iis-rewrite-rules-to-improve/
Reply all
Reply to author
Forward
0 new messages