1

My need is to Add Expires headers - while Googling I got the solution from this link. But where this file is located? Is it possible add it to my Visual Studio solution? Is it necessary to refer such file in master page?

Community
  • 1
  • 1
  • 1
    Are you sure your site is deployed on Apache server? It is not very common to folks using Apache (i.e. on LAMP stack) to use Visual Studio... – Alexei Levenkov Jul 22 '15 at 05:13
  • Are you absolutely sure you need .htaccess? To my knowledge there is no point of using it with IIS (you can search for http://www.bing.com/search?q=iis+htaccess )... If you'd be looking for just expire headers your post is simple duplicate of one of many posts like http://stackoverflow.com/questions/10825497/iis-7-5-how-do-you-add-a-dynamic-http-expires-header – Alexei Levenkov Jul 22 '15 at 05:27
  • 1
    To clarify: IIS does not support `.htaccess` as-is - you need to use `web.config` instead, but I'm not sure if that supports `Expires` headers. – Mike Rockétt Jul 22 '15 at 06:21

1 Answers1

1

If you want to set an Expires header for static content in IIS with ASP.NET you need to do it in the web.config. I blogged about this a while back here.

But here is the code to add a default 7 day expiration to the <system.webServer> node of your web.config.

<staticContent>
 <clientCache cacheControlMaxAge="7.00:00:00" cacheControlMode="UseMaxAge" />
</staticContent>
Mitchel Sellers
  • 62,228
  • 14
  • 110
  • 173