“过期"在静态内容的 http 标头中?如何 [英] "Expires" in http header for static content? how-to
本文介绍了“过期"在静态内容的 http 标头中?如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在静态内容的 http 标头中添加过期"的最佳方法是什么?例如.图片、css、js
What is the best way to add "Expires" in http header for static content? eg. images, css, js
Web 服务器是 IIS 6.0;语言是经典的 ASP
The web server is IIS 6.0; the language is classical ASP
推荐答案
你可以试试这样的:
@ECHO OFF
REM ---------------------------------------------------------------------------
REM Caching - sets the caching on static files in a web site
REM syntax
REM Caching.CMD 1 d:sitesMySiteWWWRoot*.CSS
REM
REM %1 is the WebSite ID
REM %2 is the path & Wildcard - for example, d:sitesMySiteWWWRoot*.CSS
REM _adsutil is the path to ADSUtil.VBS
REM ---------------------------------------------------------------------------
SETLOCAL
SET _adsutil=D:AppsScriptsadsutil.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 天,然后像这样运行它:
Which sets the caching value for each CSS file in a web root to 5 days, then run it like this:
Caching.CMD 1 sitewwwroot*.css
Caching.CMD 1 sitewwwroot*.js
Caching.CMD 1 sitewwwroot*.html
Caching.CMD 1 sitewwwroot*.htm
Caching.CMD 1 sitewwwroot*.gif
Caching.CMD 1 sitewwwroot*.jpg
有点痛苦,但可行.
顺便说一句 - 要获取 HttpExpires 的值,请在 GUI 中设置值,然后运行
BTW - to get the value for HttpExpires, set the value in the GUI, then run
AdsUtil.vbs ENUM W3SVC/1/root/File.txt
得到你需要的实际值
这篇关于“过期"在静态内容的 http 标头中?如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文