Last Updated: February 25, 2016
·
189
· wcp1231

Using ruby to update static file version

ruby -i.bak -rdate -pe '$_.gsub!(/(<(script|link|img)[^@%>]*=["][^"]*\.(js|css|png|jpg))/) {%Q|#{$1}?#{DateTime.now.strftime "%Y%m%d%H"}|}' ./**/*.html

it can update static file like js, css and image, like update

<link src="/static/style.css">

to

<link src="/static/style.css?2014070211">