is there a way to automate changing filenames in <link> , <script> tags

Posted by nepsdotin on Server Fault See other posts from Server Fault or by nepsdotin
Published on 2010-09-12T11:19:28Z Indexed on 2011/06/22 8:24 UTC
Read the original article Hit count: 262

when we use Expires header for text files like js, css, contents are cached in the browser, to get new content we need to change in the html file the new names in the link and script tag. When we add changes. How can we automate it.

I may have some bunch of html files in multiple folders also in subdirectories.

There would be a text file

filelist.txt

OldName                 NewName
oldfile1-ver-1.0.js      oldfile1-ver-2.0.js  
oldfile2-ver-1.0.js      oldfile2-ver-2.0.js  
oldfile3-ver-1.0.js      oldfile3-ver-2.0.js  
oldfile4-ver-1.0.js      oldfile4-ver-2.0.js  

The script should change all the oldfile1-ver-1.0.js into oldfile1-ver-2.0.js in the html, php files

I would run this script before i start uploading.

Finally the script could create a list of files and line number where it made the update.

The solution can be in PERL/PHP/BATCH or anything thats nice and elegant

© Server Fault or respective owner

Related posts about automation

Related posts about automated-install