"过期"在HTTP头中为静态内容?如何 [英] "Expires" in http header for static content? how-to

查看:115
本文介绍了"过期"在HTTP头中为静态内容?如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是补充的最佳途径过期在HTTP头中对静态内容?例如。图像,CSS,JS

What is the best way to add "Expires" in http header for static content? eg. images, css, js

该网站的服务器是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:\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天,然后运行它是这样的:

Which sets the caching value for each CSS file in a web root to 5 days, then run 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

的痛苦,但可行的种类。

Kind of painful, but workable.

顺便说一句 - 获得价值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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆