You can try something like this:
@ECHO OFF REM --------------------------------------------------------------------------- REM Caching - sets the caching on static files in a web site REM syntax REM Caching.CMD 1 d:\sites\MySite\WWWRoot\*.CSS REM REM %1 is the WebSite ID REM %2 is the path & Wildcard - for example, d:\sites\MySite\WWWRoot\*.CSS REM _adsutil is the path to ADSUtil.VBS REM --------------------------------------------------------------------------- SETLOCAL SET _adsutil=D:\Apps\Scripts\adsutil.vbs FOR %%i IN (%2) DO ( ECHO Setting Caching on %%~ni%%~xi CSCRIPT %_adsutil% CREATE W3SVC/%1/root/%%~ni%%~xi "IIsWebFile" CSCRIPT %_adsutil% SET W3SVC/%1/root/%%~ni%%~xi/HttpExpires "D, 0x69780" ECHO. )
Which sets the caching value for each CSS file in the root directory of the website for up to 5 days, then do it like this:
Caching.CMD 1 \site\wwwroot\*.css Caching.CMD 1 \site\wwwroot\*.js Caching.CMD 1 \site\wwwroot\*.html Caching.CMD 1 \site\wwwroot\*.htm Caching.CMD 1 \site\wwwroot\*.gif Caching.CMD 1 \site\wwwroot\*.jpg
The view is painful, but efficient.
BTW - to get the value for HttpExpires, set the value in the GUI, then run
AdsUtil.vbs ENUM W3SVC/1/root/File.txt
to get the desired value
source share