How to set caching of static files in IIS?

I have some static images in a folder on my IIS 6-based website that I want to download as little as possible (to save bandwidth). Content expiration expires in 30 days. Is there anything else I can do in IIS to try to maximize caching through caching, proxies, and gateways?

How to add a Cache-Control header? Anything else?

+3
source share
2 answers

http://www.galcho.com/Blog/post/2008/02/27/IIS7-How-to-set-cache-control-for-static-content.aspx

This is a blog post that says the following:

  • Allow override of static content
  • ,
+1

: "Expires" http ?

@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.
)

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, ,

AdsUtil.vbs ENUM W3SVC/1/root/File.txt

+1

Source: https://habr.com/ru/post/1699521/


All Articles