开发者

iis only Add Expires headers to images

开发者 https://www.devze.com 2022-12-16 17:17 出处:网络
Add expires headers in iis is very Easy,but this cache all the static files. now i want only add expires headers to images,how can i do that? even i want cac开发者_Go百科hed specific file?

Add expires headers in iis is very Easy,but this cache all the static files. now i want only add expires headers to images,how can i do that? even i want cac开发者_Go百科hed specific file?


  1. put all your images in one folder
  2. enter the manager--> yoursite--> images folder (or specific file)
  3. right click--> HTTP HEADERs--> Set expire header/date ! --> APPLY/OK


I've been searching for a simpler solution and I found this.

Keep your static content inside a folder (eg: css, js). Create a web.config file inside that folder. Add these following lines. Here 7 is the number of days, change it as you desire.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
        </staticContent>
    </system.webServer>
</configuration>

You are free to keep as many static content folder as you want, simply add this web.config file. Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号