Hoe stel ek die cachability van statiese lêers in IIS?
-
08-07-2019 - |
Vra
Ek het 'n paar statiese beelde in 'n gids op my IIS 6-gebaseerde webwerf wat ek wil so min as moontlik om afgelaai te word (om bandwydte te bewaar). Ek het die inhoud Expiration te verval na 30 dae gestel. Is daar enigiets anders wat ek kan doen in IIS om te probeer om die kas deur implementeer, volmag, en gateway caches te maksimeer?
Soos die toevoeging van 'n kas-Control kop? Enigiets anders?
Oplossing
http://www.galcho.com/Blog/post/2008/02/27/IIS7-How-to-set-cache-control-for-static-content.aspx
Dit is 'n blog post wat die volgende:
- Laat oorheersende statiese inhoud instelling
- stel kas instellings met behulp van volgende opdragte
- Cache dit op kliënt
Ander wenke
Hier is my antwoord van hierdie vraag: "Verval" in http kop vir statiese inhoud? hoe-om
@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
REM *******
REM SET THIS TO POINT TO adsutil.vbs - TYPICALLY c:\inetpub\adminscripts\adsutil.vbs
REM *******
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.
)
Watter stel die kas waarde vir elke CSS-lêer in 'n web wortel tot 5 dae, hardloop dit dan soos volg:
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
Tipe pynlik, maar werkbare.
BTW - ter waarde kry vir HttpExpires, stel die waarde in die GUI, dan loop
AdsUtil.vbs ENUM W3SVC/1/root/File.txt
om die werklike waarde wat jy nodig het