asp.net-mvc-2squishit

How to delete the old files that are created with change in the js and css files without manually cleaning them everytime using SquishIt framework


I am working on asp.net mvc2 project. Due to some limitations I cannot migrate the code to asp.net mvc4 version and due to this I am not able to use the Bundling and Magnification feature for bundling and minifying the js and css files. I used the SquishIt framework to work on this. Can anyone help me to know are there any other good options other than SquishIt framework to work on this task.

I used the following url to implement SquishIt framework: http://www.codethinked.com/SquishIt-The-Friendly-ASPNET-JavaScript-and-CSS-Squisher

Can anyone help me know how to delete the old files that are created with change in the js and css files without manually cleaning them everytime.

Thanks & Regards, Santosh Kumar Patro


Solution

  • The best solution for this is to not include the hash in your filename (I assume you are rendering to filename_#.ext). You'd just need to remove the '#' from your rendered filename, then SquishIt will use querystring invalidation by default. This will only keep a single copy of each bundled file on disk. If querystring invalidation won't work for you there is also a relatively new option that allows you to place the hash into the path as a directory, then scrub it out with an IIS rewrite rule.

    For more on SquishIt's support for different cache invalidation strategies read this