在http标头中为静态内容添加"Expires"的最佳方法是什么?例如.图像,css,js
Web服务器是IIS 6.0; 语言是经典的ASP
你可以尝试这样的事情:
@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. )
这将Web根目录中每个CSS文件的缓存值设置为5天,然后像这样运行:
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
有点痛苦,但可行.
BTW - 要获取HttpExpires的值,请在GUI中设置值,然后运行
AdsUtil.vbs ENUM W3SVC/1/root/File.txt
获得你需要的实际价值