Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding expire headers to Web.Config file

Tags:

iis

web-config

I'm looking to add expire headers to my website so I can set a cache time for the files.

I've found the following the example, but I'd like to set it to only cache JPG, PNG, GIF, JS and CSS files if possible?

<system.webServer>
    <staticContent>
        <clientCache cacheControlMaxAge="14.00:00:00" cacheControlMode="UseMaxAge"/>
    </staticContent>
</system.webServer>

Thanks for any help!

like image 842
Steven McLintock Avatar asked Aug 31 '26 20:08

Steven McLintock


1 Answers

What you can do is to create web.config files in the folders where your files are. (You might have folder such "Images" for images and "Js" for javascript files, "Css" for style sheets... etc.) Then, you paste yor code in those files. By doing that you apply your cache settigs to all files in those folders, regardless of the file type. This is more flexible method than applying cache settings to a particular file extension.

like image 68
walterD Avatar answered Sep 03 '26 18:09

walterD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!