Developer forum

Forum » Templates » Add hash token to filepath of css/js files?

Add hash token to filepath of css/js files?

Jacob Storgaard Jensen
Reply

Hi,

Is there a way to add a token/MD5 hash string to a css/js files path?

I know that the ControlResourcesHandler.ashx does it if resource files are registered dynamically - no clue why it doesn't when they are just hardcoded in the filelist!?... but in my case I only have one css and one js file which are compiled, minifyed and compressed locally then uploaded. I would like to be able to just add a new hashed string to the filepaths whenever a file have been changed.
 

Any ideas?


Replies

 
Nicolai Pedersen
Reply

In razor, you can mappath the files, create a IO.FileInfo on the path and then MD5 hash the lastmodified timestamp... And add that hash as a querystring parameter

 

You must be logged in to post in the forum